Skip to content

Commit c7a3c04

Browse files
committed
chore: project init
0 parents  commit c7a3c04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+8849
-0
lines changed

.commitlintrc.cjs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@vexip-ui/commitlint-config']
3+
}

.env

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
VITE_APP_TITLE = Vexip Admin
2+
3+
VITE_BASE_LANGUAGE = zh-CN

.env.development

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
VITE_USE_MOCK = true
2+
3+
VITE_BASE_PATH = /
4+
5+
VITE_DROP_CONSOLE = false
6+
7+
VITE_BASE_SERVER = http://192.168.1.39:5888
8+
9+
VITE_RESOURCE_SERVER = http://192.168.1.39:7800

.env.production

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
VITE_USE_MOCK = true
2+
3+
VITE_BASE_PATH = /
4+
5+
VITE_DROP_CONSOLE = true
6+
7+
VITE_BASE_SERVER = http://www.cnqisoft.com:5918
8+
9+
VITE_RESOURCE_SERVER = http://www.cnqisoft.com:5917

.eslintignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
dist
2+
node_modules
3+
public
4+
.husky
5+
output
6+
coverage
7+
public
8+
temp
9+
__snapshots__
10+
11+
.*rc.js
12+
.*rc.cjs
13+
*.css
14+
*.pcss
15+
*.scss
16+
*.svg
17+
*.min.*
18+
LICENSE*
19+
CHANGELOG.md
20+
package-lock.json
21+
pnpm-lock.yaml
22+
yarn.lock
23+
24+
!.github
25+
!.vitepress
26+
!.vscode

.eslintrc.cjs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
extends: ['@vexip-ui/eslint-config'],
3+
root: true
4+
}

.gitignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
package-lock.json
11+
yarn.lock
12+
pnpm-lock.yaml
13+
14+
node_modules
15+
dist
16+
dist-ssr
17+
*.local
18+
19+
# Editor directories and files
20+
.vscode/*
21+
!.vscode/extensions.json
22+
!.vscode/settings.json
23+
.idea
24+
.DS_Store
25+
*.suo
26+
*.ntvs*
27+
*.njsproj
28+
*.sln
29+
*.sw?

.husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/.lintstagedrc

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"*.{js,jsx,ts,tsx}": [
3+
"prettier --write",
4+
"eslint --fix"
5+
],
6+
"{!(package)*.json,*.code-snippets,.!(browserslist|npm)*rc}": [
7+
"prettier --write--parser json"
8+
],
9+
"package.json": [
10+
"prettier --write"
11+
],
12+
"*.{css,scss,pcss,html}": [
13+
"prettier --write",
14+
"stylelint --fix"
15+
],
16+
"*.md": [
17+
"prettier --write"
18+
],
19+
"*.vue": [
20+
"prettier --write",
21+
"eslint --fix",
22+
"stylelint --fix"
23+
]
24+
}

.husky/commit-msg

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
. "$(dirname "$0")/common.sh"
4+
5+
npx --no-install commitlint --edit "$1"

.husky/common.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
command_exists () {
2+
command -v "$1" >/dev/null 2>&1
3+
}
4+
5+
# Workaround for Windows 10, Git Bash and Yarn
6+
if command_exists winpty && test -t 1; then
7+
exec < /dev/tty
8+
fi

.husky/pre-commit

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
. "$(dirname "$0")/common.sh"
4+
5+
[ -n "$CI" ] && exit 0
6+
7+
pnpm run precommit

.prettierignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dist
2+
node_modules
3+
public
4+
.husky
5+
6+
*.svg
7+
*.sh

.prettierrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@vexip-ui/prettier-config')

.stylelintignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
node_modules
2+
dist
3+
public
4+
output
5+
coverage
6+
temp
7+
.husky
8+
9+
*.js
10+
*.cjs
11+
*.mjs
12+
*.ts
13+
*.tsx
14+
*.svg
15+
*.gif
16+
*.md

.stylelintrc.cjs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
extends: ['@vexip-ui/stylelint-config'],
3+
plugins: ['stylelint-prettier']
4+
}

.vscode/extensions.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"Vue.volar",
4+
"dbaeumer.vscode-eslint",
5+
"stylelint.vscode-stylelint",
6+
"esbenp.prettier-vscode"
7+
]
8+
}

.vscode/settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"files.associations": {
3+
".lintstagedrc": "json",
4+
".env.development": "properties",
5+
".env.production": "properties",
6+
".env.test": "test"
7+
}
8+
}

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019-present vexip-ui
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Vexip Admin
2+
3+
A management system template for [Vexip UI](https://github.com/vexip-ui/vexip-ui).
4+
5+
## License
6+
7+
All in [MIT](./LICENSE.md) license.

build/plugins/html.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { Plugin } from 'vite'
2+
3+
export interface HtmlPluginOptions {
4+
title?: string
5+
}
6+
7+
export function createHtmlPlugin(options: HtmlPluginOptions = {}): Plugin {
8+
const { title = '' } = options
9+
10+
return {
11+
name: 'plugin:html',
12+
transformIndexHtml(html) {
13+
if (!title) return html
14+
15+
return {
16+
html: html.replace(/<title>(.*?)<\/title>/, `<title>${title}</title>`),
17+
tags: []
18+
}
19+
}
20+
}
21+
}

build/plugins/icon.ts

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import { relative } from 'node:path'
2+
import { readFileSync } from 'node:fs'
3+
import glob from 'fast-glob'
4+
import { normalizePath } from 'vite'
5+
6+
import type { Plugin } from 'vite'
7+
8+
export interface IconPluginOptions {
9+
dir?: string,
10+
domId?: string
11+
}
12+
13+
interface IconFileState {
14+
id: string,
15+
code: string,
16+
mtimeMs?: number
17+
}
18+
19+
const ICON_REGISTER = 'virtual:icon-register'
20+
const XMLNS = 'http://www.w3.org/2000/svg'
21+
const XMLNS_LINK = 'http://www.w3.org/1999/xlink'
22+
const DEFAULT_DOM_ID = '__icon_symbols__'
23+
24+
const svgRE = /\.svg$/
25+
const svgTagRE = /<svg([\s\S]*?)>([\s\S]*?)<\/svg>/
26+
const idAttrRE = /id="[\s\S]*?"/g
27+
28+
export function createIconPlugin(options: IconPluginOptions = {}): Plugin {
29+
const { dir = '', domId = DEFAULT_DOM_ID } = options
30+
31+
const cache = new Map<string, IconFileState>()
32+
33+
let isBuild = false
34+
35+
async function renderModuleCode() {
36+
const entries = await glob('**/*.svg', {
37+
cwd: dir,
38+
stats: true,
39+
absolute: true
40+
})
41+
42+
let html = ''
43+
44+
for (const entry of entries) {
45+
const { path, stats: { mtimeMs } = {} } = entry
46+
const cachedStat = cache.get(path)
47+
48+
let id: string
49+
let code: string
50+
51+
if (cachedStat && cachedStat.mtimeMs === mtimeMs) {
52+
id = cachedStat.id
53+
code = cachedStat.code
54+
} else {
55+
const content = readFileSync(path, 'utf-8')
56+
const svg = content.match(svgTagRE)?.[0]
57+
58+
id = normalizePath(relative(dir, path).replace(svgRE, ''))
59+
code = (svg || '<svg></svg>')
60+
.replace(idAttrRE, '')
61+
.replace(svgTagRE, `<symbol id="${id}" $1>$2</symbol>`)
62+
63+
cache.set(path, { id, code, mtimeMs })
64+
}
65+
66+
html += code
67+
}
68+
69+
html = `
70+
if (typeof window !== 'undefined') {
71+
function loadSvg() {
72+
const body = document.body
73+
let svgDom = document.getElementById('${domId}')
74+
if(!svgDom) {
75+
svgDom = document.createElementNS('${XMLNS}', 'svg')
76+
svgDom.style.position = 'absolute'
77+
svgDom.style.width = '0'
78+
svgDom.style.height = '0'
79+
svgDom.style.pointerEvents = 'none'
80+
svgDom.id = '${domId}'
81+
svgDom.setAttribute('xmlns','${XMLNS}')
82+
svgDom.setAttribute('xmlns:link','${XMLNS_LINK}')
83+
}
84+
svgDom.innerHTML = ${JSON.stringify(html)}
85+
body.insertBefore(svgDom, body.firstChild)
86+
}
87+
if(document.readyState === 'loading') {
88+
document.addEventListener('DOMContentLoaded', loadSvg);
89+
} else {
90+
loadSvg()
91+
}
92+
}
93+
`
94+
95+
return html
96+
}
97+
98+
return {
99+
name: 'plugin:icon',
100+
configResolved(config) {
101+
isBuild = config.command === 'build'
102+
},
103+
resolveId(id) {
104+
return ICON_REGISTER === id ? id : null
105+
},
106+
async load(id, ssr) {
107+
if (!isBuild || ICON_REGISTER !== id) return null
108+
if (ssr && !isBuild) return 'export default {}'
109+
110+
return await renderModuleCode()
111+
},
112+
configureServer: ({ middlewares }) => {
113+
// middlewares.use(cors({ origin: '*' }))
114+
middlewares.use(async (req, res, next) => {
115+
const url = normalizePath(req.url!)
116+
const registerId = `/@id/${ICON_REGISTER}`
117+
118+
if (url.endsWith(registerId)) {
119+
res.setHeader('Content-Type', 'application/javascript')
120+
res.setHeader('Cache-Control', 'no-cache')
121+
122+
// res.setHeader('Etag', getEtag(content, { weak: true }))
123+
res.statusCode = 200
124+
res.end(await renderModuleCode())
125+
} else {
126+
next()
127+
}
128+
})
129+
}
130+
}
131+
}

0 commit comments

Comments
 (0)