@moluoxixi/create-app 2.0.4 → 2.0.403
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +21 -21
- package/README.md +129 -129
- package/dist/commands/create.d.ts +2 -1
- package/dist/commands/create.js +12 -8
- package/dist/commands/index.d.ts +1 -2
- package/dist/commands/index.js +1 -2
- package/dist/constants/index.d.ts +17 -0
- package/dist/constants/index.js +17 -0
- package/dist/generators/index.d.ts +3 -4
- package/dist/generators/index.js +3 -4
- package/dist/generators/project.d.ts +3 -2
- package/dist/generators/project.js +5 -4
- package/dist/generators/react.d.ts +4 -2
- package/dist/generators/react.js +10 -30
- package/dist/generators/vue.d.ts +4 -2
- package/dist/generators/vue.js +10 -31
- package/dist/index.d.ts +0 -1
- package/dist/index.js +21 -3
- package/dist/test.d.ts +5 -2
- package/dist/test.js +252 -206
- package/dist/types/ejs.d.ts +0 -1
- package/dist/types/ejs.js +0 -1
- package/dist/types/features.d.ts +1 -2
- package/dist/types/features.js +1 -1
- package/dist/types/index.d.ts +2 -4
- package/dist/types/index.js +2 -4
- package/dist/types/packageJson.d.ts +24 -0
- package/dist/types/packageJson.js +4 -0
- package/dist/types/viteConfig.d.ts +11 -9
- package/dist/types/viteConfig.js +0 -1
- package/dist/utils/deepMerge.d.ts +3 -1
- package/dist/utils/deepMerge.js +8 -1
- package/dist/utils/ejs.d.ts +3 -2
- package/dist/utils/ejs.js +2 -1
- package/dist/utils/featureMapping.d.ts +44 -0
- package/dist/utils/featureMapping.js +119 -0
- package/dist/utils/file.d.ts +22 -2
- package/dist/utils/file.js +35 -2
- package/dist/utils/generateFrameworkProject.d.ts +27 -0
- package/dist/utils/generateFrameworkProject.js +47 -0
- package/dist/utils/index.d.ts +11 -9
- package/dist/utils/index.js +11 -9
- package/dist/utils/install.d.ts +7 -4
- package/dist/utils/install.js +55 -12
- package/dist/utils/npmConfig.d.ts +15 -0
- package/dist/utils/npmConfig.js +79 -0
- package/dist/utils/prompts.d.ts +3 -2
- package/dist/utils/prompts.js +51 -5
- package/dist/utils/renderFeatures.d.ts +3 -2
- package/dist/utils/renderFeatures.js +41 -37
- package/dist/utils/renderTemplate.d.ts +13 -1
- package/dist/utils/renderTemplate.js +128 -61
- package/dist/utils/sortDependencies.d.ts +3 -2
- package/dist/utils/sortDependencies.js +3 -2
- package/dist/utils/viteConfigRender.d.ts +11 -14
- package/dist/utils/viteConfigRender.js +10 -173
- package/package.json +4 -2
- package/templates/common/base/.env +7 -7
- package/templates/common/base/.env.development +5 -5
- package/templates/common/base/.env.production +5 -5
- package/templates/common/base/package.json +23 -27
- package/templates/common/base/scripts/build.mts +37 -31
- package/templates/common/base/src/apis/index.ts +8 -8
- package/templates/common/base/src/apis/request.ts +43 -43
- package/templates/common/base/src/apis/services/example.ts +61 -40
- package/templates/common/base/src/apis/services/user.ts +33 -23
- package/templates/common/base/src/apis/types/common.ts +43 -28
- package/templates/common/base/src/apis/types/example.ts +15 -3
- package/templates/common/base/src/apis/types/index.ts +7 -7
- package/templates/common/base/src/apis/types/user.ts +39 -24
- package/templates/common/base/src/assets/fonts/index.css +7 -7
- package/templates/common/base/src/assets/styles/base.scss +72 -72
- package/templates/common/base/src/assets/styles/custom.scss +7 -7
- package/templates/common/base/src/assets/styles/tailwind.scss +6 -6
- package/templates/common/base/src/constants/index.ts +29 -29
- package/templates/common/base/src/utils/index.ts +88 -83
- package/templates/{vue/base/vite.config.ts → common/base/vite.config.ts.ejs} +28 -11
- package/templates/common/features/husky/.cz-config.cjs +35 -35
- package/templates/common/features/husky/commitlint.config.ts +32 -32
- package/templates/common/features/husky/node_modules/.bin/commitizen +17 -0
- package/templates/common/features/husky/node_modules/.bin/commitizen.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/commitizen.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/commitlint +17 -0
- package/templates/common/features/husky/node_modules/.bin/commitlint.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/commitlint.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/cz +17 -0
- package/templates/common/features/husky/node_modules/.bin/cz-cust +17 -0
- package/templates/common/features/husky/node_modules/.bin/cz-cust.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/cz-cust.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/cz-customizable +17 -0
- package/templates/common/features/husky/node_modules/.bin/cz-customizable.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/cz-customizable.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/cz.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/cz.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/git-cz +17 -0
- package/templates/common/features/husky/node_modules/.bin/git-cz.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/git-cz.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/husky +17 -0
- package/templates/common/features/husky/node_modules/.bin/husky.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/husky.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/lint-staged +17 -0
- package/templates/common/features/husky/node_modules/.bin/lint-staged.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/lint-staged.ps1 +41 -0
- package/templates/common/features/husky/package.json +6 -6
- package/templates/react/base/env.d.ts +19 -19
- package/templates/react/base/index.html +14 -14
- package/templates/react/base/node_modules/.bin/vite +17 -0
- package/templates/react/base/node_modules/.bin/vite.CMD +12 -0
- package/templates/react/base/node_modules/.bin/vite.ps1 +41 -0
- package/templates/react/base/package.json +18 -15
- package/templates/react/base/src/App.tsx +18 -18
- package/templates/react/base/src/assets/styles/main.scss +8 -8
- package/templates/react/base/src/main.tsx.ejs +51 -6
- package/templates/react/base/src/pages/about/index.tsx +14 -14
- package/templates/react/base/src/pages/home/index.tsx +14 -14
- package/templates/react/base/tsconfig.app.json +17 -17
- package/templates/react/base/tsconfig.base.json +23 -23
- package/templates/react/base/tsconfig.json +12 -12
- package/templates/react/base/tsconfig.node.json +15 -15
- package/templates/react/features/ant-design/package.json +6 -7
- package/templates/react/features/eslint/node_modules/.bin/eslint +17 -0
- package/templates/react/features/eslint/node_modules/.bin/eslint.CMD +12 -0
- package/templates/react/features/eslint/node_modules/.bin/eslint.ps1 +41 -0
- package/templates/react/features/eslint/package.json +3 -3
- package/templates/react/features/i18n/package.json +6 -7
- package/templates/react/features/i18n/src/locales/index.ts +7 -0
- package/templates/{common/base → react/features/i18n}/src/locales/lang/en.ts +30 -30
- package/templates/{common/base → react/features/i18n}/src/locales/lang/es.ts +30 -30
- package/templates/{common/base → react/features/i18n}/src/locales/lang/zh.ts +30 -30
- package/templates/react/features/manualRoutes/src/router/routes.tsx +13 -0
- package/templates/react/features/pageRoutes/package.json +1 -2
- package/templates/react/features/qiankun/package.json +6 -0
- package/templates/react/features/qiankun/src/qiankun/index.ts +80 -0
- package/templates/react/features/router/package.json +1 -1
- package/templates/react/features/sentry/package.json +6 -7
- package/templates/react/features/sentry/src/utils/sentry.ts +10 -0
- package/templates/react/features/zustand/package.json +1 -1
- package/templates/react/features/zustand/src/stores/user.ts +42 -6
- package/templates/react/features/zustand/src/types/stores.ts +8 -1
- package/templates/vue/base/env.d.ts +27 -27
- package/templates/vue/base/index.html +14 -14
- package/templates/vue/base/node_modules/.bin/vite +17 -0
- package/templates/vue/base/node_modules/.bin/vite.CMD +12 -0
- package/templates/vue/base/node_modules/.bin/vite.ps1 +41 -0
- package/templates/vue/base/node_modules/.bin/vue-tsc +17 -0
- package/templates/vue/base/node_modules/.bin/vue-tsc.CMD +12 -0
- package/templates/vue/base/node_modules/.bin/vue-tsc.ps1 +41 -0
- package/templates/vue/base/package.json +16 -13
- package/templates/vue/base/src/App.vue +13 -13
- package/templates/vue/base/src/assets/styles/main.scss +9 -9
- package/templates/vue/base/src/directives/index.ts +36 -36
- package/templates/vue/base/src/layouts/index.ts +5 -7
- package/templates/vue/base/src/main.ts.ejs +9 -25
- package/templates/vue/base/src/pages/about/index.vue +31 -31
- package/templates/vue/base/src/pages/home/index.vue +31 -31
- package/templates/vue/base/src/router/index.ts.ejs +10 -13
- package/templates/vue/base/tsconfig.app.json +17 -17
- package/templates/vue/base/tsconfig.base.json +23 -23
- package/templates/vue/base/tsconfig.json +12 -12
- package/templates/vue/base/tsconfig.node.json +15 -15
- package/templates/vue/features/ant-design-vue/package.json +6 -7
- package/templates/vue/{base → features/ant-design-vue}/src/layouts/AntDesign.vue +86 -86
- package/templates/vue/features/element-plus/package.json +6 -7
- package/templates/vue/{base → features/element-plus}/src/assets/styles/element/index.scss +27 -27
- package/templates/vue/features/element-plus/src/components/SubMenu/index.ts +9 -0
- package/templates/vue/{base → features/element-plus}/src/components/SubMenu/src/_types/index.ts +6 -6
- package/templates/vue/{base → features/element-plus}/src/components/SubMenu/src/_types/props.ts +11 -11
- package/templates/vue/{base → features/element-plus}/src/components/SubMenu/src/index.vue +24 -24
- package/templates/vue/{base → features/element-plus}/src/layouts/element.vue +81 -81
- package/templates/vue/features/eslint/node_modules/.bin/eslint +17 -0
- package/templates/vue/features/eslint/node_modules/.bin/eslint.CMD +12 -0
- package/templates/vue/features/eslint/node_modules/.bin/eslint.ps1 +41 -0
- package/templates/vue/features/eslint/package.json +3 -3
- package/templates/vue/features/i18n/package.json +5 -5
- package/templates/vue/features/i18n/src/locales/index.ts +23 -16
- package/templates/vue/features/i18n/src/locales/lang/en.ts +30 -0
- package/templates/vue/features/i18n/src/locales/lang/es.ts +30 -0
- package/templates/vue/features/i18n/src/locales/lang/zh.ts +30 -0
- package/templates/vue/features/manualRoutes/src/router/routes.ts +35 -27
- package/templates/vue/features/pageRoutes/package.json +5 -5
- package/templates/vue/features/pinia/package.json +3 -2
- package/templates/vue/features/pinia/src/stores/index.ts +8 -0
- package/templates/vue/features/pinia/src/stores/system.ts +60 -0
- package/templates/vue/features/pinia/src/stores/user.ts +33 -13
- package/templates/vue/features/qiankun/package.json +5 -5
- package/templates/vue/features/qiankun/src/qiankun/index.ts +19 -0
- package/templates/vue/features/router/package.json +1 -1
- package/templates/vue/features/sentry/package.json +6 -6
- package/templates/vue/features/sentry/src/utils/sentry.ts +12 -0
- package/dist/commands/create.d.ts.map +0 -1
- package/dist/commands/create.js.map +0 -1
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js.map +0 -1
- package/dist/generators/index.d.ts.map +0 -1
- package/dist/generators/index.js.map +0 -1
- package/dist/generators/project.d.ts.map +0 -1
- package/dist/generators/project.js.map +0 -1
- package/dist/generators/react.d.ts.map +0 -1
- package/dist/generators/react.js.map +0 -1
- package/dist/generators/vue.d.ts.map +0 -1
- package/dist/generators/vue.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/test.d.ts.map +0 -1
- package/dist/test.js.map +0 -1
- package/dist/types/ejs.d.ts.map +0 -1
- package/dist/types/ejs.js.map +0 -1
- package/dist/types/features.d.ts.map +0 -1
- package/dist/types/features.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/viteConfig.d.ts.map +0 -1
- package/dist/types/viteConfig.js.map +0 -1
- package/dist/utils/deepMerge.d.ts.map +0 -1
- package/dist/utils/deepMerge.js.map +0 -1
- package/dist/utils/ejs.d.ts.map +0 -1
- package/dist/utils/ejs.js.map +0 -1
- package/dist/utils/file.d.ts.map +0 -1
- package/dist/utils/file.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/install.d.ts.map +0 -1
- package/dist/utils/install.js.map +0 -1
- package/dist/utils/prompts.d.ts.map +0 -1
- package/dist/utils/prompts.js.map +0 -1
- package/dist/utils/renderFeatures.d.ts.map +0 -1
- package/dist/utils/renderFeatures.js.map +0 -1
- package/dist/utils/renderTemplate.d.ts.map +0 -1
- package/dist/utils/renderTemplate.js.map +0 -1
- package/dist/utils/sortDependencies.d.ts.map +0 -1
- package/dist/utils/sortDependencies.js.map +0 -1
- package/dist/utils/viteConfigRender.d.ts.map +0 -1
- package/dist/utils/viteConfigRender.js.map +0 -1
- package/templates/common/base/pnpm-workspace.yaml +0 -37
- package/templates/common/features/husky/pnpm-workspace.yaml +0 -9
- package/templates/react/base/pnpm-workspace.yaml +0 -9
- package/templates/react/base/src/stores/user.ts +0 -39
- package/templates/react/base/vite.config.ts +0 -52
- package/templates/react/features/ant-design/pnpm-workspace.yaml +0 -5
- package/templates/react/features/eslint/pnpm-workspace.yaml +0 -6
- package/templates/react/features/i18n/pnpm-workspace.yaml +0 -5
- package/templates/react/features/pageRoutes/pnpm-workspace.yaml +0 -4
- package/templates/react/features/pageRoutes/vite.config.data.ts +0 -10
- package/templates/react/features/router/pnpm-workspace.yaml +0 -3
- package/templates/react/features/sentry/pnpm-workspace.yaml +0 -5
- package/templates/react/features/sentry/vite.config.data.ts +0 -23
- package/templates/react/features/zustand/pnpm-workspace.yaml +0 -3
- package/templates/vue/base/pnpm-workspace.yaml +0 -6
- package/templates/vue/base/src/components/SubMenu/index.ts +0 -9
- package/templates/vue/base/src/stores/index.ts +0 -16
- package/templates/vue/base/src/stores/modules/system.ts +0 -52
- package/templates/vue/base/src/stores/modules/user.ts +0 -48
- package/templates/vue/features/ant-design-vue/pnpm-workspace.yaml +0 -5
- package/templates/vue/features/element-plus/pnpm-workspace.yaml +0 -5
- package/templates/vue/features/element-plus/vite.config.data.ts +0 -15
- package/templates/vue/features/eslint/pnpm-workspace.yaml +0 -6
- package/templates/vue/features/i18n/pnpm-workspace.yaml +0 -3
- package/templates/vue/features/pageRoutes/pnpm-workspace.yaml +0 -4
- package/templates/vue/features/pageRoutes/vite.config.data.ts +0 -9
- package/templates/vue/features/pinia/pnpm-workspace.yaml +0 -4
- package/templates/vue/features/qiankun/pnpm-workspace.yaml +0 -3
- package/templates/vue/features/router/pnpm-workspace.yaml +0 -3
- package/templates/vue/features/sentry/pnpm-workspace.yaml +0 -4
- package/templates/vue/features/sentry/vite.config.data.ts +0 -23
|
@@ -1,13 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 路由配置
|
|
3
|
+
* 手动配置路由表,支持懒加载
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
import type { RouteObject } from 'react-router-dom'
|
|
2
7
|
import { lazy, Suspense } from 'react'
|
|
3
8
|
|
|
4
9
|
const Home = lazy(() => import('@/pages/home'))
|
|
5
10
|
const About = lazy(() => import('@/pages/about'))
|
|
6
11
|
|
|
12
|
+
/**
|
|
13
|
+
* 懒加载包装组件
|
|
14
|
+
* @param children 要懒加载的子组件
|
|
15
|
+
* @returns 带 Suspense 的组件
|
|
16
|
+
*/
|
|
7
17
|
function LazyLoad({ children }: { children: React.ReactNode }) {
|
|
8
18
|
return <Suspense fallback={<div>Loading...</div>}>{children}</Suspense>
|
|
9
19
|
}
|
|
10
20
|
|
|
21
|
+
/**
|
|
22
|
+
* 路由配置数组
|
|
23
|
+
*/
|
|
11
24
|
export const routes: RouteObject[] = [
|
|
12
25
|
{
|
|
13
26
|
path: '/',
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import type { Router } from '@remix-run/router'
|
|
3
|
+
import {
|
|
4
|
+
renderWithQiankun,
|
|
5
|
+
qiankunWindow,
|
|
6
|
+
} from 'vite-plugin-qiankun/dist/helper'
|
|
7
|
+
|
|
8
|
+
let root: ReturnType<typeof import('react-dom/client').createRoot> | null = null
|
|
9
|
+
let router: Router | null = null
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Qiankun 微前端 Props 接口
|
|
13
|
+
*/
|
|
14
|
+
interface QiankunProps {
|
|
15
|
+
/** 容器元素(可选) */
|
|
16
|
+
container?: Element
|
|
17
|
+
/** 其他自定义属性 */
|
|
18
|
+
[key: string]: unknown
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Qiankun 渲染选项接口
|
|
23
|
+
*/
|
|
24
|
+
interface RenderOptions {
|
|
25
|
+
/** 创建 React 根节点的函数 */
|
|
26
|
+
createRoot: (container: Element | DocumentFragment) => ReturnType<typeof import('react-dom/client').createRoot>
|
|
27
|
+
/** 创建 React Router 实例的函数 */
|
|
28
|
+
createRouter: (basename?: string) => Router
|
|
29
|
+
/** 创建应用组件的函数 */
|
|
30
|
+
createApp: (router: Router) => ReactNode
|
|
31
|
+
/** 容器选择器或元素 */
|
|
32
|
+
container?: string | Element
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 设置 Qiankun 微前端
|
|
37
|
+
* @param options 渲染选项
|
|
38
|
+
*/
|
|
39
|
+
export function setupQiankun(options: RenderOptions): void {
|
|
40
|
+
const { createRoot, createRouter, createApp, container = '#root' } = options
|
|
41
|
+
|
|
42
|
+
renderWithQiankun({
|
|
43
|
+
mount(props: QiankunProps) {
|
|
44
|
+
const containerElement = props.container
|
|
45
|
+
? props.container.querySelector('#root') || props.container
|
|
46
|
+
: typeof container === 'string'
|
|
47
|
+
? document.querySelector(container)!
|
|
48
|
+
: container
|
|
49
|
+
|
|
50
|
+
root = createRoot(containerElement)
|
|
51
|
+
const basename = qiankunWindow.__POWERED_BY_QIANKUN__
|
|
52
|
+
? (qiankunWindow as { __INJECTED_PUBLIC_PATH_BY_QIANKUN__?: string }).__INJECTED_PUBLIC_PATH_BY_QIANKUN__?.split('/')[1]
|
|
53
|
+
: undefined
|
|
54
|
+
router = createRouter(basename)
|
|
55
|
+
root.render(createApp(router))
|
|
56
|
+
},
|
|
57
|
+
bootstrap() {
|
|
58
|
+
console.log('[Qiankun] bootstrap')
|
|
59
|
+
},
|
|
60
|
+
unmount() {
|
|
61
|
+
if (root) {
|
|
62
|
+
root.unmount()
|
|
63
|
+
root = null
|
|
64
|
+
router = null
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
update() {
|
|
68
|
+
console.log('[Qiankun] update')
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 判断是否运行在 Qiankun 微前端环境中
|
|
75
|
+
* @returns 是否在 Qiankun 环境中
|
|
76
|
+
*/
|
|
77
|
+
export function isQiankun(): boolean {
|
|
78
|
+
return qiankunWindow.__POWERED_BY_QIANKUN__ || false
|
|
79
|
+
}
|
|
80
|
+
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"dependencies": {
|
|
3
|
-
"@sentry/react": "
|
|
4
|
-
"@sentry/vite-plugin": "
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
1
|
+
{
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@sentry/react": "^9.27.0",
|
|
4
|
+
"@sentry/vite-plugin": "^3.5.0"
|
|
5
|
+
}
|
|
6
|
+
}
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import * as Sentry from '@sentry/react'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Sentry 配置接口
|
|
5
|
+
*/
|
|
3
6
|
interface SentryConfig {
|
|
7
|
+
/** Sentry DSN(数据源名称) */
|
|
4
8
|
dsn: string
|
|
9
|
+
/** 环境名称(可选,默认为 'production') */
|
|
5
10
|
environment?: string
|
|
11
|
+
/** 发布版本(可选) */
|
|
6
12
|
release?: string
|
|
7
13
|
}
|
|
8
14
|
|
|
15
|
+
/**
|
|
16
|
+
* 初始化 Sentry 错误监控
|
|
17
|
+
* @param config Sentry 配置
|
|
18
|
+
*/
|
|
9
19
|
export function initSentry(config: SentryConfig): void {
|
|
10
20
|
const { dsn, environment = 'production', release } = config
|
|
11
21
|
|
|
@@ -1,19 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 用户状态管理
|
|
3
|
+
* 基于 Zustand
|
|
4
|
+
*/
|
|
2
5
|
|
|
3
6
|
import { create } from 'zustand'
|
|
4
7
|
import { persist } from 'zustand/middleware'
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
/**
|
|
10
|
+
* 用户信息接口
|
|
11
|
+
*/
|
|
12
|
+
interface UserInfo {
|
|
13
|
+
/** 用户 ID */
|
|
14
|
+
id: string
|
|
15
|
+
/** 用户名 */
|
|
16
|
+
username: string
|
|
17
|
+
/** 邮箱 */
|
|
18
|
+
email: string
|
|
19
|
+
/** 头像 URL(可选) */
|
|
20
|
+
avatar?: string
|
|
21
|
+
/** 角色列表 */
|
|
22
|
+
roles: string[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 用户状态接口
|
|
27
|
+
*/
|
|
28
|
+
interface UserState {
|
|
29
|
+
/** 用户信息 */
|
|
30
|
+
userInfo: UserInfo | null
|
|
31
|
+
/** 认证 token */
|
|
32
|
+
token: string
|
|
33
|
+
/** 设置用户信息 */
|
|
34
|
+
setUserInfo: (info: UserInfo | null) => void
|
|
35
|
+
/** 设置 token */
|
|
36
|
+
setToken: (token: string) => void
|
|
37
|
+
/** 清除用户信息 */
|
|
38
|
+
clearUser: () => void
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const useUserStore = create<UserState>()(
|
|
7
42
|
persist(
|
|
8
43
|
set => ({
|
|
9
|
-
token: '',
|
|
10
44
|
userInfo: null,
|
|
11
|
-
|
|
12
|
-
setUserInfo:
|
|
13
|
-
|
|
45
|
+
token: '',
|
|
46
|
+
setUserInfo: info => set({ userInfo: info }),
|
|
47
|
+
setToken: token => set({ token }),
|
|
48
|
+
clearUser: () => set({ userInfo: null, token: '' }),
|
|
14
49
|
}),
|
|
15
50
|
{
|
|
16
51
|
name: 'user-storage',
|
|
52
|
+
partialize: state => ({ token: state.token }),
|
|
17
53
|
},
|
|
18
54
|
),
|
|
19
55
|
)
|
|
@@ -4,12 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
import type { UserInfoType } from '@/apis/types/user'
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* 用户 Store 状态类型
|
|
9
|
+
*/
|
|
8
10
|
export interface UserStateType {
|
|
11
|
+
/** 认证 token */
|
|
9
12
|
token: string
|
|
13
|
+
/** 用户信息 */
|
|
10
14
|
userInfo: UserInfoType | null
|
|
15
|
+
/** 设置 token */
|
|
11
16
|
setToken: (token: string) => void
|
|
17
|
+
/** 设置用户信息 */
|
|
12
18
|
setUserInfo: (info: UserInfoType) => void
|
|
19
|
+
/** 登出 */
|
|
13
20
|
logout: () => void
|
|
14
21
|
}
|
|
15
22
|
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 环境变量类型声明
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/// <reference types="vite/client" />
|
|
6
|
-
|
|
7
|
-
interface ImportMetaEnv {
|
|
8
|
-
readonly VITE_APP_CODE: string;
|
|
9
|
-
readonly VITE_APP_TITLE: string;
|
|
10
|
-
readonly VITE_APP_PORT: number;
|
|
11
|
-
readonly VITE_APP_VERSION: string;
|
|
12
|
-
readonly VITE_APP_ENV: string;
|
|
13
|
-
readonly VITE_API_BASE_URL: string;
|
|
14
|
-
readonly VITE_SENTRY: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface ImportMeta {
|
|
18
|
-
readonly env: ImportMetaEnv;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
declare module '*.vue' {
|
|
22
|
-
import type { DefineComponent } from 'vue';
|
|
23
|
-
|
|
24
|
-
const component: DefineComponent<object, object, unknown>;
|
|
25
|
-
export default component;
|
|
26
|
-
}
|
|
27
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 环境变量类型声明
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/// <reference types="vite/client" />
|
|
6
|
+
|
|
7
|
+
interface ImportMetaEnv {
|
|
8
|
+
readonly VITE_APP_CODE: string;
|
|
9
|
+
readonly VITE_APP_TITLE: string;
|
|
10
|
+
readonly VITE_APP_PORT: number;
|
|
11
|
+
readonly VITE_APP_VERSION: string;
|
|
12
|
+
readonly VITE_APP_ENV: string;
|
|
13
|
+
readonly VITE_API_BASE_URL: string;
|
|
14
|
+
readonly VITE_SENTRY: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface ImportMeta {
|
|
18
|
+
readonly env: ImportMetaEnv;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare module '*.vue' {
|
|
22
|
+
import type { DefineComponent } from 'vue';
|
|
23
|
+
|
|
24
|
+
const component: DefineComponent<object, object, unknown>;
|
|
25
|
+
export default component;
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="zh-CN">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
|
|
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"></div>
|
|
11
|
-
<script type="module" src="/src/main.ts"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
14
|
-
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
|
|
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"></div>
|
|
11
|
+
<script type="module" src="/src/main.ts"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
14
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/mnt/e/project/template/vite-cli/node_modules/.pnpm/vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b/node_modules/vite/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b/node_modules/vite/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/mnt/e/project/template/vite-cli/node_modules/.pnpm/vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b/node_modules/vite/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b/node_modules/vite/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../vite/bin/vite.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../vite/bin/vite.js" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@SETLOCAL
|
|
2
|
+
@IF NOT DEFINED NODE_PATH (
|
|
3
|
+
@SET "NODE_PATH=E:\project\template\vite-cli\node_modules\.pnpm\vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b\node_modules\vite\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b\node_modules\vite\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules"
|
|
4
|
+
) ELSE (
|
|
5
|
+
@SET "NODE_PATH=E:\project\template\vite-cli\node_modules\.pnpm\vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b\node_modules\vite\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b\node_modules\vite\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules;%NODE_PATH%"
|
|
6
|
+
)
|
|
7
|
+
@IF EXIST "%~dp0\node.exe" (
|
|
8
|
+
"%~dp0\node.exe" "%~dp0\..\vite\bin\vite.js" %*
|
|
9
|
+
) ELSE (
|
|
10
|
+
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
11
|
+
node "%~dp0\..\vite\bin\vite.js" %*
|
|
12
|
+
)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
3
|
+
|
|
4
|
+
$exe=""
|
|
5
|
+
$pathsep=":"
|
|
6
|
+
$env_node_path=$env:NODE_PATH
|
|
7
|
+
$new_node_path="E:\project\template\vite-cli\node_modules\.pnpm\vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b\node_modules\vite\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b\node_modules\vite\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules"
|
|
8
|
+
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
9
|
+
# Fix case when both the Windows and Linux builds of Node
|
|
10
|
+
# are installed in the same directory
|
|
11
|
+
$exe=".exe"
|
|
12
|
+
$pathsep=";"
|
|
13
|
+
} else {
|
|
14
|
+
$new_node_path="/mnt/e/project/template/vite-cli/node_modules/.pnpm/vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b/node_modules/vite/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b/node_modules/vite/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/vite@7.3.0_@types+node@22.1_7c06d9c6f7b7316383c1af6ed786169b/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules"
|
|
15
|
+
}
|
|
16
|
+
if ([string]::IsNullOrEmpty($env_node_path)) {
|
|
17
|
+
$env:NODE_PATH=$new_node_path
|
|
18
|
+
} else {
|
|
19
|
+
$env:NODE_PATH="$new_node_path$pathsep$env_node_path"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
$ret=0
|
|
23
|
+
if (Test-Path "$basedir/node$exe") {
|
|
24
|
+
# Support pipeline input
|
|
25
|
+
if ($MyInvocation.ExpectingInput) {
|
|
26
|
+
$input | & "$basedir/node$exe" "$basedir/../vite/bin/vite.js" $args
|
|
27
|
+
} else {
|
|
28
|
+
& "$basedir/node$exe" "$basedir/../vite/bin/vite.js" $args
|
|
29
|
+
}
|
|
30
|
+
$ret=$LASTEXITCODE
|
|
31
|
+
} else {
|
|
32
|
+
# Support pipeline input
|
|
33
|
+
if ($MyInvocation.ExpectingInput) {
|
|
34
|
+
$input | & "node$exe" "$basedir/../vite/bin/vite.js" $args
|
|
35
|
+
} else {
|
|
36
|
+
& "node$exe" "$basedir/../vite/bin/vite.js" $args
|
|
37
|
+
}
|
|
38
|
+
$ret=$LASTEXITCODE
|
|
39
|
+
}
|
|
40
|
+
$env:NODE_PATH=$env_node_path
|
|
41
|
+
exit $ret
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/mnt/e/project/template/vite-cli/node_modules/.pnpm/vue-tsc@2.2.12_typescript@5.8.3/node_modules/vue-tsc/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/vue-tsc@2.2.12_typescript@5.8.3/node_modules/vue-tsc/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/vue-tsc@2.2.12_typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/mnt/e/project/template/vite-cli/node_modules/.pnpm/vue-tsc@2.2.12_typescript@5.8.3/node_modules/vue-tsc/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/vue-tsc@2.2.12_typescript@5.8.3/node_modules/vue-tsc/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/vue-tsc@2.2.12_typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../vue-tsc/bin/vue-tsc.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../vue-tsc/bin/vue-tsc.js" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@SETLOCAL
|
|
2
|
+
@IF NOT DEFINED NODE_PATH (
|
|
3
|
+
@SET "NODE_PATH=E:\project\template\vite-cli\node_modules\.pnpm\vue-tsc@2.2.12_typescript@5.8.3\node_modules\vue-tsc\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\vue-tsc@2.2.12_typescript@5.8.3\node_modules\vue-tsc\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\vue-tsc@2.2.12_typescript@5.8.3\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules"
|
|
4
|
+
) ELSE (
|
|
5
|
+
@SET "NODE_PATH=E:\project\template\vite-cli\node_modules\.pnpm\vue-tsc@2.2.12_typescript@5.8.3\node_modules\vue-tsc\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\vue-tsc@2.2.12_typescript@5.8.3\node_modules\vue-tsc\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\vue-tsc@2.2.12_typescript@5.8.3\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules;%NODE_PATH%"
|
|
6
|
+
)
|
|
7
|
+
@IF EXIST "%~dp0\node.exe" (
|
|
8
|
+
"%~dp0\node.exe" "%~dp0\..\vue-tsc\bin\vue-tsc.js" %*
|
|
9
|
+
) ELSE (
|
|
10
|
+
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
11
|
+
node "%~dp0\..\vue-tsc\bin\vue-tsc.js" %*
|
|
12
|
+
)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
3
|
+
|
|
4
|
+
$exe=""
|
|
5
|
+
$pathsep=":"
|
|
6
|
+
$env_node_path=$env:NODE_PATH
|
|
7
|
+
$new_node_path="E:\project\template\vite-cli\node_modules\.pnpm\vue-tsc@2.2.12_typescript@5.8.3\node_modules\vue-tsc\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\vue-tsc@2.2.12_typescript@5.8.3\node_modules\vue-tsc\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\vue-tsc@2.2.12_typescript@5.8.3\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules"
|
|
8
|
+
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
9
|
+
# Fix case when both the Windows and Linux builds of Node
|
|
10
|
+
# are installed in the same directory
|
|
11
|
+
$exe=".exe"
|
|
12
|
+
$pathsep=";"
|
|
13
|
+
} else {
|
|
14
|
+
$new_node_path="/mnt/e/project/template/vite-cli/node_modules/.pnpm/vue-tsc@2.2.12_typescript@5.8.3/node_modules/vue-tsc/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/vue-tsc@2.2.12_typescript@5.8.3/node_modules/vue-tsc/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/vue-tsc@2.2.12_typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules"
|
|
15
|
+
}
|
|
16
|
+
if ([string]::IsNullOrEmpty($env_node_path)) {
|
|
17
|
+
$env:NODE_PATH=$new_node_path
|
|
18
|
+
} else {
|
|
19
|
+
$env:NODE_PATH="$new_node_path$pathsep$env_node_path"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
$ret=0
|
|
23
|
+
if (Test-Path "$basedir/node$exe") {
|
|
24
|
+
# Support pipeline input
|
|
25
|
+
if ($MyInvocation.ExpectingInput) {
|
|
26
|
+
$input | & "$basedir/node$exe" "$basedir/../vue-tsc/bin/vue-tsc.js" $args
|
|
27
|
+
} else {
|
|
28
|
+
& "$basedir/node$exe" "$basedir/../vue-tsc/bin/vue-tsc.js" $args
|
|
29
|
+
}
|
|
30
|
+
$ret=$LASTEXITCODE
|
|
31
|
+
} else {
|
|
32
|
+
# Support pipeline input
|
|
33
|
+
if ($MyInvocation.ExpectingInput) {
|
|
34
|
+
$input | & "node$exe" "$basedir/../vue-tsc/bin/vue-tsc.js" $args
|
|
35
|
+
} else {
|
|
36
|
+
& "node$exe" "$basedir/../vue-tsc/bin/vue-tsc.js" $args
|
|
37
|
+
}
|
|
38
|
+
$ret=$LASTEXITCODE
|
|
39
|
+
}
|
|
40
|
+
$env:NODE_PATH=$env_node_path
|
|
41
|
+
exit $ret
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vue-project",
|
|
3
|
-
"scripts": {
|
|
4
|
-
"type-check": "vue-tsc --noEmit"
|
|
5
|
-
},
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"vue": "
|
|
8
|
-
},
|
|
9
|
-
"devDependencies": {
|
|
10
|
-
"@
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "vue-project",
|
|
3
|
+
"scripts": {
|
|
4
|
+
"type-check": "vue-tsc --noEmit"
|
|
5
|
+
},
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"vue": "^3.5.13"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@moluoxixi/css-module-global-root-plugin": "latest",
|
|
11
|
+
"@moluoxixi/vite-config": "latest",
|
|
12
|
+
"@vue-macros/volar": "^3.0.0-beta.15",
|
|
13
|
+
"vue-tsc": "^2.1.30",
|
|
14
|
+
"vite": "latest"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* 根组件
|
|
4
|
-
*/
|
|
5
|
-
</script>
|
|
6
|
-
|
|
7
|
-
<template>
|
|
8
|
-
<RouterView />
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<style scoped>
|
|
12
|
-
</style>
|
|
13
|
-
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* 根组件
|
|
4
|
+
*/
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<RouterView />
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<style scoped>
|
|
12
|
+
</style>
|
|
13
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 主样式文件
|
|
3
|
-
* 导入所有样式
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
@import './base.scss';
|
|
7
|
-
@import './custom.scss';
|
|
8
|
-
@import './tailwind.scss';
|
|
9
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 主样式文件
|
|
3
|
+
* 导入所有样式
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@import './base.scss';
|
|
7
|
+
@import './custom.scss';
|
|
8
|
+
@import './tailwind.scss';
|
|
9
|
+
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 自定义指令
|
|
3
|
-
* 全局指令注册
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { App } from 'vue';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 注册全局指令
|
|
10
|
-
* @param app Vue 应用实例
|
|
11
|
-
*/
|
|
12
|
-
export default function directives(app: App): void {
|
|
13
|
-
// v-focus 自动聚焦指令
|
|
14
|
-
app.directive('focus', {
|
|
15
|
-
mounted(el: HTMLElement) {
|
|
16
|
-
el.focus();
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// v-loading 加载状态指令
|
|
21
|
-
app.directive('loading', {
|
|
22
|
-
mounted(el: HTMLElement, binding) {
|
|
23
|
-
if (binding.value) {
|
|
24
|
-
el.classList.add('is-loading');
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
updated(el: HTMLElement, binding) {
|
|
28
|
-
if (binding.value) {
|
|
29
|
-
el.classList.add('is-loading');
|
|
30
|
-
} else {
|
|
31
|
-
el.classList.remove('is-loading');
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 自定义指令
|
|
3
|
+
* 全局指令注册
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { App } from 'vue';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 注册全局指令
|
|
10
|
+
* @param app Vue 应用实例
|
|
11
|
+
*/
|
|
12
|
+
export default function directives(app: App): void {
|
|
13
|
+
// v-focus 自动聚焦指令
|
|
14
|
+
app.directive('focus', {
|
|
15
|
+
mounted(el: HTMLElement) {
|
|
16
|
+
el.focus();
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// v-loading 加载状态指令
|
|
21
|
+
app.directive('loading', {
|
|
22
|
+
mounted(el: HTMLElement, binding) {
|
|
23
|
+
if (binding.value) {
|
|
24
|
+
el.classList.add('is-loading');
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
updated(el: HTMLElement, binding) {
|
|
28
|
+
if (binding.value) {
|
|
29
|
+
el.classList.add('is-loading');
|
|
30
|
+
} else {
|
|
31
|
+
el.classList.remove('is-loading');
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|