@moluoxixi/create-app 2.0.404 → 2.0.406
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/dist/commands/create.js +0 -1
- package/dist/generators/react.js +0 -2
- package/dist/generators/vue.js +0 -2
- package/dist/test.js +8 -0
- package/dist/utils/deepMerge.js +1 -1
- package/dist/utils/featureMapping.d.ts +2 -2
- package/dist/utils/featureMapping.js +3 -5
- package/dist/utils/generateFrameworkProject.d.ts +0 -4
- package/dist/utils/generateFrameworkProject.js +1 -1
- package/dist/utils/install.js +1 -1
- package/dist/utils/prompts.js +4 -30
- package/dist/utils/renderTemplate.js +9 -4
- package/package.json +2 -1
- package/templates/common/base/.gitmodules +4 -0
- package/templates/common/base/package.json +2 -0
- package/templates/common/base/vite.config.ts.ejs +13 -2
- package/templates/common/features/husky/package.json +2 -1
- package/templates/react/base/package.json +3 -1
- package/templates/react/{features/qiankun → base}/src/qiankun/index.ts +4 -0
- package/templates/react/base/src/stores/index.ts +5 -0
- package/templates/react/base/src/stores/user.ts +55 -0
- package/templates/react/{base/src/router/index.tsx.ejs → features/manualRoutes/src/router/index.tsx} +6 -5
- package/templates/react/features/pageRoutes/src/router/index.tsx +30 -0
- package/templates/vue/base/package.json +5 -1
- package/templates/vue/base/src/App.vue +1 -0
- package/templates/vue/base/src/assets/styles/base.scss +69 -0
- package/templates/vue/base/src/assets/styles/custom.scss +40 -0
- package/templates/vue/base/src/assets/styles/tailwind.scss +3 -0
- package/templates/vue/base/src/layouts/index.ts +22 -0
- package/templates/vue/base/src/main.ts.ejs +1 -0
- package/templates/vue/base/src/router/layout.vue +15 -0
- package/templates/vue/base/src/stores/index.ts +6 -0
- package/templates/vue/base/src/stores/modules/system.ts +51 -0
- package/templates/vue/base/src/stores/modules/user.ts +41 -0
- package/templates/vue/base/src/utils/index.ts +5 -0
- package/templates/vue/base/src/utils/modifyComponent.tsx +43 -0
- package/templates/vue/base/tsconfig.app.json +25 -16
- package/templates/vue/base/tsconfig.base.json +29 -22
- package/templates/vue/base/tsconfig.json +11 -11
- package/templates/vue/base/tsconfig.node.json +14 -14
- package/templates/vue/features/element-plus/src/assets/styles/element/fixQiankun.scss +10 -0
- package/templates/vue/features/element-plus/src/assets/styles/element/index.scss +3 -0
- package/templates/vue/features/element-plus/src/components/SubMenu/src/_types/index.ts +1 -5
- package/templates/vue/features/element-plus/src/components/SubMenu/src/_types/props.ts +16 -10
- package/templates/vue/features/element-plus/src/components/SubMenu/src/index.vue +60 -23
- package/templates/vue/features/element-plus/src/layouts/element.vue +106 -70
- package/templates/vue/features/manualRoutes/package.json +7 -0
- package/templates/vue/features/manualRoutes/src/router/index.ts +45 -0
- package/templates/vue/features/manualRoutes/src/router/layout.vue +11 -5
- package/templates/vue/features/manualRoutes/src/stores/index.ts +6 -0
- package/templates/vue/features/manualRoutes/src/stores/modules/system.ts +51 -0
- package/templates/vue/features/manualRoutes/src/stores/modules/user.ts +41 -0
- package/templates/vue/features/pageRoutes/package.json +4 -1
- package/templates/vue/features/pageRoutes/src/router/index.ts +46 -0
- package/templates/vue/features/pageRoutes/src/router/layout.vue +15 -0
- package/templates/vue/features/pageRoutes/src/stores/index.ts +6 -0
- package/templates/vue/features/pageRoutes/src/stores/modules/system.ts +51 -0
- package/templates/vue/features/pageRoutes/src/stores/modules/user.ts +41 -0
- package/templates/vue/features/sentry/package.json +3 -1
- package/templates/vue/features/sentry/src/stores/index.ts +13 -0
- package/templates/react/features/qiankun/package.json +0 -5
- package/templates/vue/base/src/router/index.ts.ejs +0 -36
- package/templates/vue/features/pinia/package.json +0 -7
- package/templates/vue/features/pinia/src/stores/index.ts +0 -15
- package/templates/vue/features/pinia/src/stores/system.ts +0 -59
- package/templates/vue/features/pinia/src/stores/user.ts +0 -56
- package/templates/vue/features/qiankun/node_modules/.bin/jiti +0 -17
- package/templates/vue/features/qiankun/node_modules/.bin/jiti.CMD +0 -12
- package/templates/vue/features/qiankun/node_modules/.bin/jiti.ps1 +0 -41
- package/templates/vue/features/qiankun/node_modules/.bin/sass +0 -17
- package/templates/vue/features/qiankun/node_modules/.bin/sass.CMD +0 -12
- package/templates/vue/features/qiankun/node_modules/.bin/sass.ps1 +0 -41
- package/templates/vue/features/qiankun/node_modules/.bin/terser +0 -17
- package/templates/vue/features/qiankun/node_modules/.bin/terser.CMD +0 -12
- package/templates/vue/features/qiankun/node_modules/.bin/terser.ps1 +0 -41
- package/templates/vue/features/qiankun/node_modules/.bin/tsc +0 -17
- package/templates/vue/features/qiankun/node_modules/.bin/tsc.CMD +0 -12
- package/templates/vue/features/qiankun/node_modules/.bin/tsc.ps1 +0 -41
- package/templates/vue/features/qiankun/node_modules/.bin/tsserver +0 -17
- package/templates/vue/features/qiankun/node_modules/.bin/tsserver.CMD +0 -12
- package/templates/vue/features/qiankun/node_modules/.bin/tsserver.ps1 +0 -41
- package/templates/vue/features/qiankun/node_modules/.bin/tsx +0 -17
- package/templates/vue/features/qiankun/node_modules/.bin/tsx.CMD +0 -12
- package/templates/vue/features/qiankun/node_modules/.bin/tsx.ps1 +0 -41
- package/templates/vue/features/qiankun/node_modules/.bin/vite +0 -17
- package/templates/vue/features/qiankun/node_modules/.bin/vite.CMD +0 -12
- package/templates/vue/features/qiankun/node_modules/.bin/vite.ps1 +0 -41
- package/templates/vue/features/qiankun/node_modules/.bin/yaml +0 -17
- package/templates/vue/features/qiankun/node_modules/.bin/yaml.CMD +0 -12
- package/templates/vue/features/qiankun/node_modules/.bin/yaml.ps1 +0 -41
- package/templates/vue/features/qiankun/package.json +0 -5
- package/templates/vue/features/qiankun/src/qiankun/index.ts +0 -74
- package/templates/vue/features/router/node_modules/.bin/tsc +0 -17
- package/templates/vue/features/router/node_modules/.bin/tsc.CMD +0 -12
- package/templates/vue/features/router/node_modules/.bin/tsc.ps1 +0 -41
- package/templates/vue/features/router/node_modules/.bin/tsserver +0 -17
- package/templates/vue/features/router/node_modules/.bin/tsserver.CMD +0 -12
- package/templates/vue/features/router/node_modules/.bin/tsserver.ps1 +0 -41
- package/templates/vue/features/router/package.json +0 -5
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/jiti +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/jiti.CMD +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/jiti.ps1 +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/sass +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/sass.CMD +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/sass.ps1 +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/terser +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/terser.CMD +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/terser.ps1 +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/tsc +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/tsc.CMD +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/tsc.ps1 +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/tsserver +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/tsserver.CMD +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/tsserver.ps1 +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/tsx +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/tsx.CMD +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/tsx.ps1 +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/vite +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/vite.CMD +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/vite.ps1 +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/yaml +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/yaml.CMD +0 -0
- /package/templates/{react/features/qiankun → vue/features/manualRoutes}/node_modules/.bin/yaml.ps1 +0 -0
- /package/templates/vue/features/{pinia → pageRoutes}/node_modules/.bin/tsc +0 -0
- /package/templates/vue/features/{pinia → pageRoutes}/node_modules/.bin/tsc.CMD +0 -0
- /package/templates/vue/features/{pinia → pageRoutes}/node_modules/.bin/tsc.ps1 +0 -0
- /package/templates/vue/features/{pinia → pageRoutes}/node_modules/.bin/tsserver +0 -0
- /package/templates/vue/features/{pinia → pageRoutes}/node_modules/.bin/tsserver.CMD +0 -0
- /package/templates/vue/features/{pinia → pageRoutes}/node_modules/.bin/tsserver.ps1 +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { cloneDeep } from 'lodash-es'
|
|
2
|
+
import { assign, isEmpty } from 'radash'
|
|
3
|
+
import { routes } from './routes'
|
|
4
|
+
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
|
|
5
|
+
import { createRouter, createWebHistory } from 'vue-router'
|
|
6
|
+
|
|
7
|
+
// 手动配置的路由
|
|
8
|
+
const Routes = [
|
|
9
|
+
{
|
|
10
|
+
path: '/',
|
|
11
|
+
name: 'layout',
|
|
12
|
+
component: () => import('@/router/layout.vue' as string),
|
|
13
|
+
redirect: routes[0]?.path,
|
|
14
|
+
children: routes,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
path: '/:pathMatch(.*)*',
|
|
18
|
+
redirect: '/',
|
|
19
|
+
},
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
function getRouter(props: any) {
|
|
23
|
+
let base: string
|
|
24
|
+
const routes = cloneDeep(Routes)
|
|
25
|
+
if (qiankunWindow.__POWERED_BY_QIANKUN__) {
|
|
26
|
+
const { activeRule } = props.data
|
|
27
|
+
base = activeRule
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
base = import.meta.env.VITE_APP_CODE
|
|
31
|
+
}
|
|
32
|
+
const router = createRouter({
|
|
33
|
+
history: createWebHistory(base),
|
|
34
|
+
routes,
|
|
35
|
+
})
|
|
36
|
+
router.beforeEach((_, from, next) => {
|
|
37
|
+
if (isEmpty(history.state.current)) {
|
|
38
|
+
assign(history.state, { current: from.fullPath })
|
|
39
|
+
}
|
|
40
|
+
next()
|
|
41
|
+
})
|
|
42
|
+
return router
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default getRouter
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<component :is="layout" />
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
-
<script
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
<script lang="ts" setup>
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
import layouts from '@/layouts'
|
|
8
|
+
import { useSystemStore } from '@/stores/modules/system'
|
|
9
|
+
|
|
10
|
+
const systemInfo = useSystemStore()
|
|
11
|
+
const layoutType = computed(() => systemInfo.layout)
|
|
12
|
+
const layout = computed(() => layouts[layoutType.value])
|
|
9
13
|
</script>
|
|
14
|
+
|
|
15
|
+
<style lang="scss" scoped></style>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { store } from '../index.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 系统对象
|
|
6
|
+
* @returns {object} 系统存储对象
|
|
7
|
+
*/
|
|
8
|
+
const systemStore = defineStore('system', {
|
|
9
|
+
state: () => ({
|
|
10
|
+
/**
|
|
11
|
+
* 主题颜色
|
|
12
|
+
* @type {string}
|
|
13
|
+
*/
|
|
14
|
+
themeColor: '#3a77ff',
|
|
15
|
+
/**
|
|
16
|
+
* 布局
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
layout: 'element',
|
|
20
|
+
/**
|
|
21
|
+
* 系统编码
|
|
22
|
+
* @type {string}
|
|
23
|
+
*/
|
|
24
|
+
systemCode: import.meta.env.VITE_APP_CODE || '',
|
|
25
|
+
}),
|
|
26
|
+
actions: {
|
|
27
|
+
setSystemCode(systemCode: string) {
|
|
28
|
+
// 将当前的主题颜色设置为传入的颜色
|
|
29
|
+
this.systemCode = systemCode
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* 设置布局
|
|
33
|
+
* @param {string} layout - 新的布局
|
|
34
|
+
*/
|
|
35
|
+
setLayout(layout: string) {
|
|
36
|
+
this.layout = layout
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* 设置主题颜色
|
|
40
|
+
* @param {string} color - 新的主题颜色
|
|
41
|
+
*/
|
|
42
|
+
setTheme(color: string) {
|
|
43
|
+
// 将当前的主题颜色设置为传入的颜色
|
|
44
|
+
this.themeColor = color
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
export function useSystemStore() {
|
|
50
|
+
return systemStore(store)
|
|
51
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import { store } from '@/stores'
|
|
4
|
+
|
|
5
|
+
export const userStore = defineStore(
|
|
6
|
+
'user',
|
|
7
|
+
() => {
|
|
8
|
+
// 定义token
|
|
9
|
+
const token = ref('')
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 用户登录
|
|
13
|
+
* @param userInfo 用户信息(可选,qiankun 环境下可能从主应用传递)
|
|
14
|
+
*/
|
|
15
|
+
const userLogin = async (userInfo?: any) => {
|
|
16
|
+
// 如果传递了用户信息,可以在这里处理登录逻辑
|
|
17
|
+
// 例如:设置 token、保存用户信息等
|
|
18
|
+
if (userInfo) {
|
|
19
|
+
// 可以根据实际需求处理用户信息
|
|
20
|
+
console.log('User login with info:', userInfo)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 获取 token
|
|
26
|
+
* @returns token 值
|
|
27
|
+
*/
|
|
28
|
+
const getToken = () => {
|
|
29
|
+
return token.value
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return { getToken, userLogin, token }
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
persist: true,
|
|
36
|
+
},
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
export function useUserStore() {
|
|
40
|
+
return userStore(store)
|
|
41
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { cloneDeep } from 'lodash-es'
|
|
2
|
+
import { assign, isEmpty } from 'radash'
|
|
3
|
+
import routes from '~pages'
|
|
4
|
+
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
|
|
5
|
+
import { createRouter, createWebHistory } from 'vue-router'
|
|
6
|
+
|
|
7
|
+
// 自动生成的路由
|
|
8
|
+
const routesChildrens = routes
|
|
9
|
+
const Routes = [
|
|
10
|
+
{
|
|
11
|
+
path: '/',
|
|
12
|
+
name: 'layout',
|
|
13
|
+
component: () => import('@/router/layout.vue' as string),
|
|
14
|
+
redirect: routes[0]?.path,
|
|
15
|
+
children: routesChildrens,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
path: '/:pathMatch(.*)*',
|
|
19
|
+
redirect: '/',
|
|
20
|
+
},
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
function getRouter(props: any) {
|
|
24
|
+
let base: string
|
|
25
|
+
const routes = cloneDeep(Routes)
|
|
26
|
+
if (qiankunWindow.__POWERED_BY_QIANKUN__) {
|
|
27
|
+
const { activeRule } = props.data
|
|
28
|
+
base = activeRule
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
base = import.meta.env.VITE_APP_CODE
|
|
32
|
+
}
|
|
33
|
+
const router = createRouter({
|
|
34
|
+
history: createWebHistory(base),
|
|
35
|
+
routes,
|
|
36
|
+
})
|
|
37
|
+
router.beforeEach((_, from, next) => {
|
|
38
|
+
if (isEmpty(history.state.current)) {
|
|
39
|
+
assign(history.state, { current: from.fullPath })
|
|
40
|
+
}
|
|
41
|
+
next()
|
|
42
|
+
})
|
|
43
|
+
return router
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default getRouter
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="layout" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script lang="ts" setup>
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
import layouts from '@/layouts'
|
|
8
|
+
import { useSystemStore } from '@/stores/modules/system'
|
|
9
|
+
|
|
10
|
+
const systemInfo = useSystemStore()
|
|
11
|
+
const layoutType = computed(() => systemInfo.layout)
|
|
12
|
+
const layout = computed(() => layouts[layoutType.value])
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<style lang="scss" scoped></style>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { store } from '../index.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 系统对象
|
|
6
|
+
* @returns {object} 系统存储对象
|
|
7
|
+
*/
|
|
8
|
+
const systemStore = defineStore('system', {
|
|
9
|
+
state: () => ({
|
|
10
|
+
/**
|
|
11
|
+
* 主题颜色
|
|
12
|
+
* @type {string}
|
|
13
|
+
*/
|
|
14
|
+
themeColor: '#3a77ff',
|
|
15
|
+
/**
|
|
16
|
+
* 布局
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
layout: 'element',
|
|
20
|
+
/**
|
|
21
|
+
* 系统编码
|
|
22
|
+
* @type {string}
|
|
23
|
+
*/
|
|
24
|
+
systemCode: import.meta.env.VITE_APP_CODE || '',
|
|
25
|
+
}),
|
|
26
|
+
actions: {
|
|
27
|
+
setSystemCode(systemCode: string) {
|
|
28
|
+
// 将当前的主题颜色设置为传入的颜色
|
|
29
|
+
this.systemCode = systemCode
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* 设置布局
|
|
33
|
+
* @param {string} layout - 新的布局
|
|
34
|
+
*/
|
|
35
|
+
setLayout(layout: string) {
|
|
36
|
+
this.layout = layout
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* 设置主题颜色
|
|
40
|
+
* @param {string} color - 新的主题颜色
|
|
41
|
+
*/
|
|
42
|
+
setTheme(color: string) {
|
|
43
|
+
// 将当前的主题颜色设置为传入的颜色
|
|
44
|
+
this.themeColor = color
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
export function useSystemStore() {
|
|
50
|
+
return systemStore(store)
|
|
51
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import { store } from '@/stores'
|
|
4
|
+
|
|
5
|
+
export const userStore = defineStore(
|
|
6
|
+
'user',
|
|
7
|
+
() => {
|
|
8
|
+
// 定义token
|
|
9
|
+
const token = ref('')
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 用户登录
|
|
13
|
+
* @param userInfo 用户信息(可选,qiankun 环境下可能从主应用传递)
|
|
14
|
+
*/
|
|
15
|
+
const userLogin = async (userInfo?: any) => {
|
|
16
|
+
// 如果传递了用户信息,可以在这里处理登录逻辑
|
|
17
|
+
// 例如:设置 token、保存用户信息等
|
|
18
|
+
if (userInfo) {
|
|
19
|
+
// 可以根据实际需求处理用户信息
|
|
20
|
+
console.log('User login with info:', userInfo)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 获取 token
|
|
26
|
+
* @returns token 值
|
|
27
|
+
*/
|
|
28
|
+
const getToken = () => {
|
|
29
|
+
return token.value
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return { getToken, userLogin, token }
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
persist: true,
|
|
36
|
+
},
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
export function useUserStore() {
|
|
40
|
+
return userStore(store)
|
|
41
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pinia Store 配置
|
|
3
|
+
* 配置 Pinia 状态管理,集成持久化插件和 Sentry 监控插件
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createSentryPiniaPlugin } from '@sentry/vue'
|
|
7
|
+
import { createPinia } from 'pinia'
|
|
8
|
+
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
|
9
|
+
|
|
10
|
+
const store = createPinia()
|
|
11
|
+
store.use(piniaPluginPersistedstate)
|
|
12
|
+
store.use(createSentryPiniaPlugin())
|
|
13
|
+
export { store }
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 路由配置
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
<% if (qiankun) { -%>
|
|
6
|
-
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
|
|
7
|
-
<% } -%>
|
|
8
|
-
import { createRouter, createWebHistory } from 'vue-router'
|
|
9
|
-
<% if (routeMode === 'file-system') { -%>
|
|
10
|
-
import routes from '~pages'
|
|
11
|
-
<% } else { -%>
|
|
12
|
-
import { routes } from './routes'
|
|
13
|
-
<% } -%>
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 获取路由实例
|
|
17
|
-
* @param props 路由属性
|
|
18
|
-
* @returns 路由实例
|
|
19
|
-
*/
|
|
20
|
-
export default function getRouter(props: Record<string, unknown> = {}) {
|
|
21
|
-
const router = createRouter({
|
|
22
|
-
history: createWebHistory(
|
|
23
|
-
<% if (qiankun) { -%>
|
|
24
|
-
qiankunWindow.__POWERED_BY_QIANKUN__
|
|
25
|
-
? '/sub-app/'
|
|
26
|
-
: import.meta.env.BASE_URL,
|
|
27
|
-
<% } else { -%>
|
|
28
|
-
import.meta.env.BASE_URL,
|
|
29
|
-
<% } -%>
|
|
30
|
-
),
|
|
31
|
-
routes,
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
return router
|
|
35
|
-
}
|
|
36
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pinia 状态管理配置
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { createPinia } from 'pinia'
|
|
6
|
-
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
|
7
|
-
|
|
8
|
-
export const store = createPinia()
|
|
9
|
-
|
|
10
|
-
// 使用持久化插件
|
|
11
|
-
store.use(piniaPluginPersistedstate)
|
|
12
|
-
|
|
13
|
-
export * from './system'
|
|
14
|
-
// 导出 store 模块
|
|
15
|
-
export * from './user'
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 系统状态管理
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { defineStore } from 'pinia'
|
|
6
|
-
import { ref } from 'vue'
|
|
7
|
-
|
|
8
|
-
export type ThemeType = 'light' | 'dark'
|
|
9
|
-
|
|
10
|
-
export const useSystemStore = defineStore(
|
|
11
|
-
'system',
|
|
12
|
-
() => {
|
|
13
|
-
/** 当前主题 */
|
|
14
|
-
const theme = ref<ThemeType>('light')
|
|
15
|
-
|
|
16
|
-
/** 当前语言 */
|
|
17
|
-
const language = ref<string>('zh')
|
|
18
|
-
|
|
19
|
-
/** 侧边栏折叠状态 */
|
|
20
|
-
const sidebarCollapsed = ref<boolean>(false)
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 设置主题
|
|
24
|
-
* @param value 主题类型('light' 或 'dark')
|
|
25
|
-
*/
|
|
26
|
-
function setTheme(value: ThemeType): void {
|
|
27
|
-
theme.value = value
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 设置语言
|
|
32
|
-
* @param value 语言代码(如 'zh', 'en', 'es')
|
|
33
|
-
*/
|
|
34
|
-
function setLanguage(value: string): void {
|
|
35
|
-
language.value = value
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 切换侧边栏折叠状态
|
|
40
|
-
*/
|
|
41
|
-
function toggleSidebar(): void {
|
|
42
|
-
sidebarCollapsed.value = !sidebarCollapsed.value
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
theme,
|
|
47
|
-
language,
|
|
48
|
-
sidebarCollapsed,
|
|
49
|
-
setTheme,
|
|
50
|
-
setLanguage,
|
|
51
|
-
toggleSidebar,
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
persist: {
|
|
56
|
-
pick: ['theme', 'language', 'sidebarCollapsed'],
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
)
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 用户状态管理
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { UserInfo } from '@/apis/types'
|
|
6
|
-
import { defineStore } from 'pinia'
|
|
7
|
-
import { ref } from 'vue'
|
|
8
|
-
|
|
9
|
-
export const useUserStore = defineStore(
|
|
10
|
-
'user',
|
|
11
|
-
() => {
|
|
12
|
-
/** 用户信息 */
|
|
13
|
-
const userInfo = ref<UserInfo | null>(null)
|
|
14
|
-
|
|
15
|
-
/** token */
|
|
16
|
-
const token = ref<string>('')
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 设置用户信息
|
|
20
|
-
* @param info 用户信息,为 null 时清空
|
|
21
|
-
*/
|
|
22
|
-
function setUserInfo(info: UserInfo | null): void {
|
|
23
|
-
userInfo.value = info
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 设置 token
|
|
28
|
-
* @param value token 值
|
|
29
|
-
*/
|
|
30
|
-
function setToken(value: string): void {
|
|
31
|
-
token.value = value
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 清除用户信息
|
|
36
|
-
* 清空用户信息和 token
|
|
37
|
-
*/
|
|
38
|
-
function clearUser(): void {
|
|
39
|
-
userInfo.value = null
|
|
40
|
-
token.value = ''
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
userInfo,
|
|
45
|
-
token,
|
|
46
|
-
setUserInfo,
|
|
47
|
-
setToken,
|
|
48
|
-
clearUser,
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
persist: {
|
|
53
|
-
pick: ['token'],
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
)
|
|
@@ -1,17 +0,0 @@
|
|
|
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/jiti@2.6.1/node_modules/jiti/lib/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/jiti@2.6.1/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/jiti@2.6.1/node_modules/jiti/lib/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/jiti@2.6.1/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/../../../../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs" "$@"
|
|
15
|
-
else
|
|
16
|
-
exec node "$basedir/../../../../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs" "$@"
|
|
17
|
-
fi
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
@SETLOCAL
|
|
2
|
-
@IF NOT DEFINED NODE_PATH (
|
|
3
|
-
@SET "NODE_PATH=E:\project\template\vite-cli\node_modules\.pnpm\jiti@2.6.1\node_modules\jiti\lib\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\jiti@2.6.1\node_modules\jiti\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\jiti@2.6.1\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\jiti@2.6.1\node_modules\jiti\lib\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\jiti@2.6.1\node_modules\jiti\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\jiti@2.6.1\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\..\..\..\..\..\..\node_modules\.pnpm\jiti@2.6.1\node_modules\jiti\lib\jiti-cli.mjs" %*
|
|
9
|
-
) ELSE (
|
|
10
|
-
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
11
|
-
node "%~dp0\..\..\..\..\..\..\node_modules\.pnpm\jiti@2.6.1\node_modules\jiti\lib\jiti-cli.mjs" %*
|
|
12
|
-
)
|
|
@@ -1,41 +0,0 @@
|
|
|
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\jiti@2.6.1\node_modules\jiti\lib\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\jiti@2.6.1\node_modules\jiti\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\jiti@2.6.1\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/jiti@2.6.1/node_modules/jiti/lib/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/jiti@2.6.1/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/../../../../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs" $args
|
|
27
|
-
} else {
|
|
28
|
-
& "$basedir/node$exe" "$basedir/../../../../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs" $args
|
|
29
|
-
}
|
|
30
|
-
$ret=$LASTEXITCODE
|
|
31
|
-
} else {
|
|
32
|
-
# Support pipeline input
|
|
33
|
-
if ($MyInvocation.ExpectingInput) {
|
|
34
|
-
$input | & "node$exe" "$basedir/../../../../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs" $args
|
|
35
|
-
} else {
|
|
36
|
-
& "node$exe" "$basedir/../../../../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs" $args
|
|
37
|
-
}
|
|
38
|
-
$ret=$LASTEXITCODE
|
|
39
|
-
}
|
|
40
|
-
$env:NODE_PATH=$env_node_path
|
|
41
|
-
exit $ret
|
|
@@ -1,17 +0,0 @@
|
|
|
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/sass@1.97.1/node_modules/sass/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/sass@1.97.1/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/sass@1.97.1/node_modules/sass/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/sass@1.97.1/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/../../../../../../node_modules/.pnpm/sass@1.97.1/node_modules/sass/sass.js" "$@"
|
|
15
|
-
else
|
|
16
|
-
exec node "$basedir/../../../../../../node_modules/.pnpm/sass@1.97.1/node_modules/sass/sass.js" "$@"
|
|
17
|
-
fi
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
@SETLOCAL
|
|
2
|
-
@IF NOT DEFINED NODE_PATH (
|
|
3
|
-
@SET "NODE_PATH=E:\project\template\vite-cli\node_modules\.pnpm\sass@1.97.1\node_modules\sass\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\sass@1.97.1\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\sass@1.97.1\node_modules\sass\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\sass@1.97.1\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\..\..\..\..\..\..\node_modules\.pnpm\sass@1.97.1\node_modules\sass\sass.js" %*
|
|
9
|
-
) ELSE (
|
|
10
|
-
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
11
|
-
node "%~dp0\..\..\..\..\..\..\node_modules\.pnpm\sass@1.97.1\node_modules\sass\sass.js" %*
|
|
12
|
-
)
|