Skip to content

Commit

Permalink
feat(projects): init project
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Oct 21, 2023
0 parents commit 7d09cad
Show file tree
Hide file tree
Showing 189 changed files with 9,980 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
VITE_BASE_URL=/

VITE_APP_TITLE=SoybeanAdmin

VITE_APP_DESC=SoybeanAdmin is a fresh and elegant admin template

# the prefix of the icon name
VITE_ICON_PREFIX=icon

# the prefix of the local svg icon component, must include VITE_ICON_PREFIX
# format {VITE_ICON_PREFIX}-{local icon name}
VITE_ICON_LOCAL_PREFIX=icon-local
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_HTTP_PROXY=Y

1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_ROUTER_HISTORY_MODE=hash
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "sa/vue",
"settings": {
"import/core-modules": ["uno.css", "~icons/*", "virtual:svg-icons-register"]
}
}
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
!.vscode/launch.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

package-lock.json
yarn.lock
pnpm-lock.yaml
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
registry=https://registry.npmmirror.com/
shamefully-hoist=true
17 changes: 17 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"recommendations": [
"antfu.unocss",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"formulahendry.auto-complete-tag",
"formulahendry.auto-close-tag",
"formulahendry.auto-rename-tag",
"kisstkondoros.vscode-gutter-preview",
"mariusalchimavicius.json-to-ts",
"mhutchie.git-graph",
"sdras.vue-vscode-snippets",
"vue.volar",
"vue.vscode-typescript-vue-plugin"
]
}
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Vue debugger",
"url": "http://localhost:9527",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "launch",
"name": "TS debugger",
"skipFiles": ["<node_internals>/**"],
"runtimeArgs": ["--loader", "tsx"],
"program": "${relativeFile}"
}
]
}
60 changes: 60 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"cSpell.words": [
"Antd",
"antv",
"clsx",
"colord",
"consola",
"EDITMSG",
"espree",
"execa",
"heroicons",
"hexcode",
"iconify",
"INDEXEDDB",
"jiti",
"kolorist",
"Laba",
"localforage",
"LOCALSTORAGE",
"nocheck",
"nprogress",
"ofetch",
"preflights",
"sider",
"tada",
"Uncapitalize",
"unocss",
"unplugin",
"VITE",
"vitepress",
"vueuse",
"WEBSQL",
"wechat"
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.fontLigatures": true,
"editor.formatOnSave": false,
"editor.quickSuggestions": {
"strings": true
},
"editor.tabSize": 2,
"files.associations": {
"*.env.*": "dotenv",
"*.svg": "html"
},
"files.eol": "\n",
"i18n-ally.displayLanguage": "zh-CN",
"i18n-ally.enabledParsers": ["ts"],
"i18n-ally.enabledFrameworks": ["vue"],
"i18n-ally.editor.preferEditor": true,
"i18n-ally.keystyle": "nested",
"i18n-ally.localesPaths": ["src/locales/lang"],
"unocss.root": ["./"],
"[html][css][less][scss][sass][markdown][yaml][yml][json][jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @sa/antd

SoybeanAdmin AntDesign
1 change: 1 addition & 0 deletions build/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './plugins';
26 changes: 26 additions & 0 deletions build/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { PluginOption } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import VueDevtools from 'vite-plugin-vue-devtools';
import progress from 'vite-plugin-progress';
import { setupElegantRouter } from './router';
import { setupUnocss } from './unocss';
import { setupUnplugin } from './unplugin';

export function setupVitePlugins(viteEnv: Env.ImportMeta) {
const plugins: PluginOption = [
vue({
script: {
defineModel: true
}
}),
vueJsx(),
VueDevtools(),
setupElegantRouter(),
setupUnocss(viteEnv),
...setupUnplugin(viteEnv),
progress()
];

return plugins;
}
24 changes: 24 additions & 0 deletions build/plugins/router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import ElegantVueRouter from '@elegant-router/vue/vite';
import type { RouteKey } from '@elegant-router/types';

export function setupElegantRouter() {
return ElegantVueRouter({
layouts: {
base: 'src/layouts/base-layout/index.vue',
blank: 'src/layouts/blank-layout/index.vue'
},
routePathTransformer(routeName, routePath) {
const key = routeName as RouteKey;

if (key === 'login') {
const modules: UnionKey.LoginModule[] = ['pwd-login', 'code-login', 'register', 'reset-pwd', 'bind-wechat'];

const moduleReg = modules.join('|');

return `/login/:module(${moduleReg})?`;
}

return routePath;
}
});
}
33 changes: 33 additions & 0 deletions build/plugins/unocss.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import path from 'node:path';
import unocss from '@unocss/vite';
import presetIcons from '@unocss/preset-icons';
import { FileSystemIconLoader } from '@iconify/utils/lib/loader/node-loaders';

export function setupUnocss(viteEnv: Env.ImportMeta) {
const { VITE_ICON_PREFIX, VITE_ICON_LOCAL_PREFIX } = viteEnv;

const localIconPath = path.join(process.cwd(), 'src/assets/svg-icon');

/**
* the name of the local icon collection
*/
const collectionName = VITE_ICON_LOCAL_PREFIX.replace(`${VITE_ICON_PREFIX}-`, '');

return unocss({
presets: [
presetIcons({
prefix: `${VITE_ICON_PREFIX}-`,
scale: 1,
extraProperties: {
display: 'inline-block'
},
collections: {
[collectionName]: FileSystemIconLoader(localIconPath, svg =>
svg.replace(/^<svg\s/, '<svg width="1em" height="1em" ')
)
},
warn: true
})
]
});
}
48 changes: 48 additions & 0 deletions build/plugins/unplugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import path from 'node:path';
import type { PluginOption } from 'vite';
import Icons from 'unplugin-icons/vite';
import IconsResolver from 'unplugin-icons/resolver';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';

export function setupUnplugin(viteEnv: Env.ImportMeta) {
const { VITE_ICON_PREFIX, VITE_ICON_LOCAL_PREFIX } = viteEnv;

const localIconPath = path.join(process.cwd(), 'src/assets/svg-icon');

/**
* the name of the local icon collection
*/
const collectionName = VITE_ICON_LOCAL_PREFIX.replace(`${VITE_ICON_PREFIX}-`, '');

const plugins: PluginOption[] = [
Icons({
compiler: 'vue3',
customCollections: {
[collectionName]: FileSystemIconLoader(localIconPath, svg =>
svg.replace(/^<svg\s/, '<svg width="1em" height="1em" ')
)
},
scale: 1,
defaultClass: 'inline-block'
}),
Components({
dts: 'src/typings/components.d.ts',
types: [{ from: 'vue-router', names: ['RouterLink', 'RouterView'] }],
resolvers: [
ElementPlusResolver(),
IconsResolver({ customCollections: [collectionName], componentPrefix: VITE_ICON_PREFIX })
]
}),
createSvgIconsPlugin({
iconDirs: [localIconPath],
symbolId: `${VITE_ICON_LOCAL_PREFIX}-[dir]-[name]`,
inject: 'body-last',
customDomId: '__SVG_ICON_LOCAL__'
})
];

return plugins;
}
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>%VITE_APP_TITLE%</title>
</head>
<body>
<div id="app">
<div id="appLoading"></div>
</div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
Loading

0 comments on commit 7d09cad

Please sign in to comment.