Skip to content

Commit 7d09cad

Browse files
committed
feat(projects): init project
0 parents  commit 7d09cad

File tree

189 files changed

+9980
-0
lines changed

Some content is hidden

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

189 files changed

+9980
-0
lines changed

.env

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
VITE_BASE_URL=/
2+
3+
VITE_APP_TITLE=SoybeanAdmin
4+
5+
VITE_APP_DESC=SoybeanAdmin is a fresh and elegant admin template
6+
7+
# the prefix of the icon name
8+
VITE_ICON_PREFIX=icon
9+
10+
# the prefix of the local svg icon component, must include VITE_ICON_PREFIX
11+
# format {VITE_ICON_PREFIX}-{local icon name}
12+
VITE_ICON_LOCAL_PREFIX=icon-local

.env.development

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
VITE_HTTP_PROXY=Y
2+

.env.production

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_ROUTER_HISTORY_MODE=hash

.eslintrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "sa/vue",
3+
"settings": {
4+
"import/core-modules": ["uno.css", "~icons/*", "virtual:svg-icons-register"]
5+
}
6+
}

.gitignore

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
node_modules
11+
.DS_Store
12+
dist
13+
dist-ssr
14+
coverage
15+
*.local
16+
17+
/cypress/videos/
18+
/cypress/screenshots/
19+
20+
# Editor directories and files
21+
.vscode/*
22+
!.vscode/extensions.json
23+
!.vscode/settings.json
24+
!.vscode/launch.json
25+
.idea
26+
*.suo
27+
*.ntvs*
28+
*.njsproj
29+
*.sln
30+
*.sw?
31+
32+
package-lock.json
33+
yarn.lock
34+
pnpm-lock.yaml

.npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
registry=https://registry.npmmirror.com/
2+
shamefully-hoist=true

.vscode/extensions.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"recommendations": [
3+
"antfu.unocss",
4+
"dbaeumer.vscode-eslint",
5+
"editorconfig.editorconfig",
6+
"esbenp.prettier-vscode",
7+
"formulahendry.auto-complete-tag",
8+
"formulahendry.auto-close-tag",
9+
"formulahendry.auto-rename-tag",
10+
"kisstkondoros.vscode-gutter-preview",
11+
"mariusalchimavicius.json-to-ts",
12+
"mhutchie.git-graph",
13+
"sdras.vue-vscode-snippets",
14+
"vue.volar",
15+
"vue.vscode-typescript-vue-plugin"
16+
]
17+
}

.vscode/launch.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "chrome",
6+
"request": "launch",
7+
"name": "Vue debugger",
8+
"url": "http://localhost:9527",
9+
"webRoot": "${workspaceFolder}"
10+
},
11+
{
12+
"type": "node",
13+
"request": "launch",
14+
"name": "TS debugger",
15+
"skipFiles": ["<node_internals>/**"],
16+
"runtimeArgs": ["--loader", "tsx"],
17+
"program": "${relativeFile}"
18+
}
19+
]
20+
}

.vscode/settings.json

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"cSpell.words": [
3+
"Antd",
4+
"antv",
5+
"clsx",
6+
"colord",
7+
"consola",
8+
"EDITMSG",
9+
"espree",
10+
"execa",
11+
"heroicons",
12+
"hexcode",
13+
"iconify",
14+
"INDEXEDDB",
15+
"jiti",
16+
"kolorist",
17+
"Laba",
18+
"localforage",
19+
"LOCALSTORAGE",
20+
"nocheck",
21+
"nprogress",
22+
"ofetch",
23+
"preflights",
24+
"sider",
25+
"tada",
26+
"Uncapitalize",
27+
"unocss",
28+
"unplugin",
29+
"VITE",
30+
"vitepress",
31+
"vueuse",
32+
"WEBSQL",
33+
"wechat"
34+
],
35+
"editor.codeActionsOnSave": {
36+
"source.fixAll.eslint": true
37+
},
38+
"editor.fontLigatures": true,
39+
"editor.formatOnSave": false,
40+
"editor.quickSuggestions": {
41+
"strings": true
42+
},
43+
"editor.tabSize": 2,
44+
"files.associations": {
45+
"*.env.*": "dotenv",
46+
"*.svg": "html"
47+
},
48+
"files.eol": "\n",
49+
"i18n-ally.displayLanguage": "zh-CN",
50+
"i18n-ally.enabledParsers": ["ts"],
51+
"i18n-ally.enabledFrameworks": ["vue"],
52+
"i18n-ally.editor.preferEditor": true,
53+
"i18n-ally.keystyle": "nested",
54+
"i18n-ally.localesPaths": ["src/locales/lang"],
55+
"unocss.root": ["./"],
56+
"[html][css][less][scss][sass][markdown][yaml][yml][json][jsonc]": {
57+
"editor.defaultFormatter": "esbenp.prettier-vscode",
58+
"editor.formatOnSave": true
59+
}
60+
}

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @sa/antd
2+
3+
SoybeanAdmin AntDesign

build/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './plugins';

build/plugins/index.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { PluginOption } from 'vite';
2+
import vue from '@vitejs/plugin-vue';
3+
import vueJsx from '@vitejs/plugin-vue-jsx';
4+
import VueDevtools from 'vite-plugin-vue-devtools';
5+
import progress from 'vite-plugin-progress';
6+
import { setupElegantRouter } from './router';
7+
import { setupUnocss } from './unocss';
8+
import { setupUnplugin } from './unplugin';
9+
10+
export function setupVitePlugins(viteEnv: Env.ImportMeta) {
11+
const plugins: PluginOption = [
12+
vue({
13+
script: {
14+
defineModel: true
15+
}
16+
}),
17+
vueJsx(),
18+
VueDevtools(),
19+
setupElegantRouter(),
20+
setupUnocss(viteEnv),
21+
...setupUnplugin(viteEnv),
22+
progress()
23+
];
24+
25+
return plugins;
26+
}

build/plugins/router.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import ElegantVueRouter from '@elegant-router/vue/vite';
2+
import type { RouteKey } from '@elegant-router/types';
3+
4+
export function setupElegantRouter() {
5+
return ElegantVueRouter({
6+
layouts: {
7+
base: 'src/layouts/base-layout/index.vue',
8+
blank: 'src/layouts/blank-layout/index.vue'
9+
},
10+
routePathTransformer(routeName, routePath) {
11+
const key = routeName as RouteKey;
12+
13+
if (key === 'login') {
14+
const modules: UnionKey.LoginModule[] = ['pwd-login', 'code-login', 'register', 'reset-pwd', 'bind-wechat'];
15+
16+
const moduleReg = modules.join('|');
17+
18+
return `/login/:module(${moduleReg})?`;
19+
}
20+
21+
return routePath;
22+
}
23+
});
24+
}

build/plugins/unocss.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import path from 'node:path';
2+
import unocss from '@unocss/vite';
3+
import presetIcons from '@unocss/preset-icons';
4+
import { FileSystemIconLoader } from '@iconify/utils/lib/loader/node-loaders';
5+
6+
export function setupUnocss(viteEnv: Env.ImportMeta) {
7+
const { VITE_ICON_PREFIX, VITE_ICON_LOCAL_PREFIX } = viteEnv;
8+
9+
const localIconPath = path.join(process.cwd(), 'src/assets/svg-icon');
10+
11+
/**
12+
* the name of the local icon collection
13+
*/
14+
const collectionName = VITE_ICON_LOCAL_PREFIX.replace(`${VITE_ICON_PREFIX}-`, '');
15+
16+
return unocss({
17+
presets: [
18+
presetIcons({
19+
prefix: `${VITE_ICON_PREFIX}-`,
20+
scale: 1,
21+
extraProperties: {
22+
display: 'inline-block'
23+
},
24+
collections: {
25+
[collectionName]: FileSystemIconLoader(localIconPath, svg =>
26+
svg.replace(/^<svg\s/, '<svg width="1em" height="1em" ')
27+
)
28+
},
29+
warn: true
30+
})
31+
]
32+
});
33+
}

build/plugins/unplugin.ts

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import path from 'node:path';
2+
import type { PluginOption } from 'vite';
3+
import Icons from 'unplugin-icons/vite';
4+
import IconsResolver from 'unplugin-icons/resolver';
5+
import Components from 'unplugin-vue-components/vite';
6+
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
7+
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
8+
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
9+
10+
export function setupUnplugin(viteEnv: Env.ImportMeta) {
11+
const { VITE_ICON_PREFIX, VITE_ICON_LOCAL_PREFIX } = viteEnv;
12+
13+
const localIconPath = path.join(process.cwd(), 'src/assets/svg-icon');
14+
15+
/**
16+
* the name of the local icon collection
17+
*/
18+
const collectionName = VITE_ICON_LOCAL_PREFIX.replace(`${VITE_ICON_PREFIX}-`, '');
19+
20+
const plugins: PluginOption[] = [
21+
Icons({
22+
compiler: 'vue3',
23+
customCollections: {
24+
[collectionName]: FileSystemIconLoader(localIconPath, svg =>
25+
svg.replace(/^<svg\s/, '<svg width="1em" height="1em" ')
26+
)
27+
},
28+
scale: 1,
29+
defaultClass: 'inline-block'
30+
}),
31+
Components({
32+
dts: 'src/typings/components.d.ts',
33+
types: [{ from: 'vue-router', names: ['RouterLink', 'RouterView'] }],
34+
resolvers: [
35+
ElementPlusResolver(),
36+
IconsResolver({ customCollections: [collectionName], componentPrefix: VITE_ICON_PREFIX })
37+
]
38+
}),
39+
createSvgIconsPlugin({
40+
iconDirs: [localIconPath],
41+
symbolId: `${VITE_ICON_LOCAL_PREFIX}-[dir]-[name]`,
42+
inject: 'body-last',
43+
customDomId: '__SVG_ICON_LOCAL__'
44+
})
45+
];
46+
47+
return plugins;
48+
}

index.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
<html lang="zh-cmn-Hans">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" href="/favicon.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>%VITE_APP_TITLE%</title>
8+
</head>
9+
<body>
10+
<div id="app">
11+
<div id="appLoading"></div>
12+
</div>
13+
<script type="module" src="/src/main.ts"></script>
14+
</body>
15+
</html>

0 commit comments

Comments
 (0)