@moluoxixi/create-app 2.0.404 → 2.0.407
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/README.md +41 -14
- package/dist/commands/create.js +9 -10
- 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.d.ts +2 -1
- package/dist/utils/install.js +4 -3
- 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 +19 -15
- 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,69 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--primary-color: #3a77ff; /* 主色调 */
|
|
3
|
+
--primary-color-1: #3a81ff; /* 辅助色1 */
|
|
4
|
+
--primary-color-2: #518fff; /* 辅助色2 */
|
|
5
|
+
--primary-color-3: #53a0fd; /* 辅助色3 */
|
|
6
|
+
--primary-color-4: #f7faff; /* 辅助色4 */
|
|
7
|
+
--success-color: #0eb67f; /* 辅助色5 */
|
|
8
|
+
--success-color-1: #f6fffc; /* 辅助色6 */
|
|
9
|
+
--warning-color: #f5ab01; /* 提醒色 */
|
|
10
|
+
--danger-color: #ef6b53; /* 警告色 */
|
|
11
|
+
|
|
12
|
+
/* 文字颜色 */
|
|
13
|
+
--text-color: #2a3651;
|
|
14
|
+
--text-color-1: #29354f;
|
|
15
|
+
--text-color-disable: #a9aeb9;
|
|
16
|
+
--text-color-choose: #3a77ff;
|
|
17
|
+
--text-color-white: white;
|
|
18
|
+
|
|
19
|
+
/* 边框色 */
|
|
20
|
+
--border-color-1: #dcdfe6;
|
|
21
|
+
--border-color-2: #b1b6bd;
|
|
22
|
+
--border-color-3: #e3e6e9;
|
|
23
|
+
--border-color-4: #e0e4e8;
|
|
24
|
+
--border-color-5: #0317c4bf;
|
|
25
|
+
--border-color-6: #7ba4ff;
|
|
26
|
+
|
|
27
|
+
/* 背景色 */
|
|
28
|
+
--bg-color-1: #f1f2f4;
|
|
29
|
+
--bg-color-2: #fafbfc;
|
|
30
|
+
--bg-color-3: #29354f;
|
|
31
|
+
--bg-color-4: #f5f7fa;
|
|
32
|
+
--bg-color-5: #f6f9ff;
|
|
33
|
+
--bg-color-6: #ebf2ff;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
*,
|
|
37
|
+
*::before,
|
|
38
|
+
*::after {
|
|
39
|
+
box-sizing: border-box;
|
|
40
|
+
margin: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
::-webkit-scrollbar {
|
|
44
|
+
width: 6px;
|
|
45
|
+
height: 6px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
::-webkit-scrollbar-thumb {
|
|
49
|
+
background-color: #dddee0; /* 设置滑块的颜色 */
|
|
50
|
+
border-radius: 5px; /* 设置滑块的圆角 */
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
body {
|
|
54
|
+
color: var(--text-color);
|
|
55
|
+
transition:
|
|
56
|
+
color 0.5s,
|
|
57
|
+
background-color 0.5s;
|
|
58
|
+
font-size: 14px;
|
|
59
|
+
font-family: SourceHanSans-Regular, serif;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#app {
|
|
63
|
+
margin: 0;
|
|
64
|
+
padding: 0;
|
|
65
|
+
font-weight: normal;
|
|
66
|
+
background: #f1f2f4;
|
|
67
|
+
height: 100%;
|
|
68
|
+
overflow-y: auto;
|
|
69
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
.text-bold {
|
|
2
|
+
font-family: SourceHanSans-Semibold, serif;
|
|
3
|
+
font-weight: bold;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.text-medium {
|
|
7
|
+
font-family: SourceHanSans-Medium, serif;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.text-regular {
|
|
11
|
+
font-family: SourceHanSans-Regular, serif;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.text-light {
|
|
15
|
+
font-family: SourceHanSans-Light, serif;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.box-shadow {
|
|
19
|
+
box-shadow: 0 2px 10px 0 rgb(52 81 212 / 20%);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.rounded-0 {
|
|
23
|
+
border-radius: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.rounded-4 {
|
|
27
|
+
border-radius: 4px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.rounded-8 {
|
|
31
|
+
border-radius: 8px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.rounded-12 {
|
|
35
|
+
border-radius: 12px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.rounded-16 {
|
|
39
|
+
border-radius: 16px;
|
|
40
|
+
}
|
|
@@ -2,3 +2,25 @@
|
|
|
2
2
|
* 布局组件导出
|
|
3
3
|
* 注意:具体的布局组件在对应的 UI 库 feature 中
|
|
4
4
|
*/
|
|
5
|
+
import type { App, Component } from 'vue'
|
|
6
|
+
|
|
7
|
+
const layoutFiles = import.meta.glob('./*.vue', { eager: true, import: 'default' })
|
|
8
|
+
const layouts = Object.keys(layoutFiles).reduce((modules, modulePath) => {
|
|
9
|
+
const nameArr: string[] = modulePath.split('/')
|
|
10
|
+
const name: string | undefined
|
|
11
|
+
= nameArr.at(-1) === 'index.vue' ? nameArr.at(-2) : nameArr.at(-1)?.slice(0, -4)
|
|
12
|
+
const layout: Component = layoutFiles[modulePath] as Component
|
|
13
|
+
if (!layout)
|
|
14
|
+
return modules
|
|
15
|
+
if (name) {
|
|
16
|
+
modules[name!] = layout as Component
|
|
17
|
+
}
|
|
18
|
+
return modules
|
|
19
|
+
}, {} as any)
|
|
20
|
+
layouts.install = function (app: App) {
|
|
21
|
+
const layoutNames = Object.keys(layouts)
|
|
22
|
+
layoutNames.forEach((name) => {
|
|
23
|
+
app.component(name, layouts[name!])
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
export default layouts
|
|
@@ -21,6 +21,7 @@ import getRouter from './router'
|
|
|
21
21
|
// 导入样式文件
|
|
22
22
|
<% if (uiLibrary === 'element-plus') { -%>
|
|
23
23
|
import '@/assets/styles/element/index.scss'
|
|
24
|
+
import '@/assets/styles/element/fixQiankun.scss'
|
|
24
25
|
<% } -%>
|
|
25
26
|
import '@/assets/styles/main.scss'
|
|
26
27
|
import '@/assets/fonts/index.css'
|
|
@@ -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,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 组件修改工具
|
|
3
|
+
* 用于修改组件的行为,特别是 Element Plus 组件在 qiankun 环境下的行为
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ComponentInstance } from 'vue'
|
|
7
|
+
import { computed, defineComponent } from 'vue'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 使用修改后的 props 包装组件
|
|
11
|
+
* @param OriginalComponent 原始组件
|
|
12
|
+
* @param modifier 属性修改函数
|
|
13
|
+
* @returns 包装后的组件
|
|
14
|
+
*/
|
|
15
|
+
function withModifiedProps(
|
|
16
|
+
OriginalComponent: ComponentInstance<any>,
|
|
17
|
+
modifier = (v: any) => v,
|
|
18
|
+
) {
|
|
19
|
+
return defineComponent({
|
|
20
|
+
name: OriginalComponent.name,
|
|
21
|
+
setup(_: any, { attrs, slots }) {
|
|
22
|
+
const modifiedProps = computed(() => modifier(attrs))
|
|
23
|
+
return () => <OriginalComponent {...modifiedProps.value} v-slots={slots} />
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 修改组件的行为
|
|
30
|
+
* @param app Vue 应用实例
|
|
31
|
+
* @param components 需要修改的组件数组
|
|
32
|
+
* @param modifier 属性修改函数
|
|
33
|
+
*/
|
|
34
|
+
export function modifyComponents(
|
|
35
|
+
app: any,
|
|
36
|
+
components: ComponentInstance<any>[],
|
|
37
|
+
modifier = (v: any) => v,
|
|
38
|
+
) {
|
|
39
|
+
components.forEach((component) => {
|
|
40
|
+
const newComponent = withModifiedProps(component, modifier)
|
|
41
|
+
app.component(newComponent.name, newComponent)
|
|
42
|
+
})
|
|
43
|
+
}
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"types": [
|
|
7
|
+
"vite/client"
|
|
8
|
+
],
|
|
9
|
+
"composite": true
|
|
10
|
+
},
|
|
11
|
+
"vueCompilerOptions": {
|
|
12
|
+
"plugins": [
|
|
13
|
+
"@vue-macros/volar/define-models",
|
|
14
|
+
"@vue-macros/volar/define-slots",
|
|
15
|
+
"@vue-macros/volar/define-props",
|
|
16
|
+
"@vue-macros/volar/define-emits"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"exclude": [
|
|
20
|
+
"dist",
|
|
21
|
+
"node_modules",
|
|
22
|
+
"cypress",
|
|
23
|
+
"vite.config.ts"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
{
|
|
2
|
+
"lib": [
|
|
3
|
+
"DOM",
|
|
4
|
+
"ESNext"
|
|
5
|
+
],
|
|
6
|
+
"compilerOptions": {
|
|
7
|
+
"target": "ESNext",
|
|
8
|
+
"jsx": "preserve",
|
|
9
|
+
"baseUrl": ".",
|
|
10
|
+
"paths": {
|
|
11
|
+
"@/*": [
|
|
12
|
+
"src/*"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"allowJs": true,
|
|
17
|
+
"strict": true,
|
|
18
|
+
"strictNullChecks": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noEmit": false,
|
|
21
|
+
"esModuleInterop": true,
|
|
22
|
+
"forceConsistentCasingInFileNames": true,
|
|
23
|
+
"isolatedModules": true,
|
|
24
|
+
"skipLibCheck": true,
|
|
25
|
+
"allowImportingTsExtensions": false,
|
|
26
|
+
"composite": true,
|
|
27
|
+
"declaration": true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"
|
|
3
|
-
"references": [
|
|
4
|
-
{
|
|
5
|
-
"path": "./tsconfig.app.json"
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
"path": "./tsconfig.node.json"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"references": [
|
|
4
|
+
{
|
|
5
|
+
"path": "./tsconfig.app.json"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"path": "./tsconfig.node.json"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "nodenext",
|
|
6
|
+
"noEmit": false,
|
|
7
|
+
"allowImportingTsExtensions": true,
|
|
8
|
+
"rewriteRelativeImportExtensions": true,
|
|
9
|
+
"composite": true
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"vite.config.ts"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
export interface subMenuRouteMetaType {
|
|
2
|
+
title?: string
|
|
3
|
+
[key: string]: unknown
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface subMenuRouteType {
|
|
7
|
+
path?: string
|
|
8
|
+
name?: string
|
|
9
|
+
meta?: subMenuRouteMetaType
|
|
10
|
+
children?: subMenuRouteType[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface propsType {
|
|
14
|
+
routes: subMenuRouteType[]
|
|
15
|
+
menuHeight?: number
|
|
16
|
+
}
|
|
@@ -1,23 +1,60 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<template
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<template
|
|
3
|
+
v-for="(route, index) in props.routes"
|
|
4
|
+
:key="getRouteKey(route, index)"
|
|
5
|
+
>
|
|
6
|
+
<ElSubMenu
|
|
7
|
+
v-if="hasChildren(route)"
|
|
8
|
+
:teleported="false"
|
|
9
|
+
:index="getRouteIndex(route, index)"
|
|
10
|
+
>
|
|
11
|
+
<template #title>
|
|
12
|
+
{{ getRouteTitle(route) }}
|
|
13
|
+
</template>
|
|
14
|
+
<div :style="`max-height: calc(100vh - ${props.menuHeight || 0}px - 30px);overflow: auto`">
|
|
15
|
+
<SubMenu :routes="route.children ?? []" />
|
|
16
|
+
</div>
|
|
17
|
+
</ElSubMenu>
|
|
18
|
+
|
|
19
|
+
<ElMenuItem
|
|
20
|
+
v-else
|
|
21
|
+
:index="getRouteIndex(route, index)"
|
|
22
|
+
>
|
|
23
|
+
{{ getRouteTitle(route) }}
|
|
24
|
+
</ElMenuItem>
|
|
25
|
+
</template>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
import type { propsType, subMenuRouteType } from './_types'
|
|
30
|
+
|
|
31
|
+
import { ElMenuItem, ElSubMenu } from 'element-plus'
|
|
32
|
+
|
|
33
|
+
defineOptions({
|
|
34
|
+
name: 'SubMenu',
|
|
35
|
+
inheritAttrs: false,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const props = withDefaults(defineProps<propsType>(), {
|
|
39
|
+
routes: () => [],
|
|
40
|
+
menuHeight: 60,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
function getRouteKey(route: subMenuRouteType, index: number): string {
|
|
44
|
+
return route.path ?? `${index}`
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function getRouteTitle(route: subMenuRouteType): string {
|
|
48
|
+
const fallback = route.name ?? ''
|
|
49
|
+
const metaTitle = route.meta?.title ?? ''
|
|
50
|
+
return metaTitle || fallback
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getRouteIndex(route: subMenuRouteType, index: number): string {
|
|
54
|
+
return route.path ?? `${index}`
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function hasChildren(route: subMenuRouteType): boolean {
|
|
58
|
+
return Array.isArray(route.children) && route.children.length > 0
|
|
59
|
+
}
|
|
60
|
+
</script>
|