@moluoxixi/create-app 2.0.1
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 -0
- package/README.md +129 -0
- package/dist/commands/create.d.ts +10 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +89 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +5 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/generators/index.d.ts +7 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +7 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/project.d.ts +11 -0
- package/dist/generators/project.d.ts.map +1 -0
- package/dist/generators/project.js +26 -0
- package/dist/generators/project.js.map +1 -0
- package/dist/generators/react.d.ts +10 -0
- package/dist/generators/react.d.ts.map +1 -0
- package/dist/generators/react.js +39 -0
- package/dist/generators/react.js.map +1 -0
- package/dist/generators/vue.d.ts +10 -0
- package/dist/generators/vue.d.ts.map +1 -0
- package/dist/generators/vue.js +40 -0
- package/dist/generators/vue.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/test.d.ts +6 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +364 -0
- package/dist/test.js.map +1 -0
- package/dist/types/ejs.d.ts +11 -0
- package/dist/types/ejs.d.ts.map +1 -0
- package/dist/types/ejs.js +5 -0
- package/dist/types/ejs.js.map +1 -0
- package/dist/types/features.d.ts +26 -0
- package/dist/types/features.d.ts.map +1 -0
- package/dist/types/features.js +41 -0
- package/dist/types/features.js.map +1 -0
- package/dist/types/index.d.ts +59 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/viteConfig.d.ts +17 -0
- package/dist/types/viteConfig.d.ts.map +1 -0
- package/dist/types/viteConfig.js +6 -0
- package/dist/types/viteConfig.js.map +1 -0
- package/dist/utils/deepMerge.d.ts +8 -0
- package/dist/utils/deepMerge.d.ts.map +1 -0
- package/dist/utils/deepMerge.js +33 -0
- package/dist/utils/deepMerge.js.map +1 -0
- package/dist/utils/ejs.d.ts +19 -0
- package/dist/utils/ejs.d.ts.map +1 -0
- package/dist/utils/ejs.js +30 -0
- package/dist/utils/ejs.js.map +1 -0
- package/dist/utils/file.d.ts +70 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +119 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/install.d.ts +17 -0
- package/dist/utils/install.d.ts.map +1 -0
- package/dist/utils/install.js +37 -0
- package/dist/utils/install.js.map +1 -0
- package/dist/utils/prompts.d.ts +16 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +180 -0
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/renderFeatures.d.ts +18 -0
- package/dist/utils/renderFeatures.d.ts.map +1 -0
- package/dist/utils/renderFeatures.js +72 -0
- package/dist/utils/renderFeatures.js.map +1 -0
- package/dist/utils/renderTemplate.d.ts +6 -0
- package/dist/utils/renderTemplate.d.ts.map +1 -0
- package/dist/utils/renderTemplate.js +102 -0
- package/dist/utils/renderTemplate.js.map +1 -0
- package/dist/utils/sortDependencies.d.ts +6 -0
- package/dist/utils/sortDependencies.d.ts.map +1 -0
- package/dist/utils/sortDependencies.js +22 -0
- package/dist/utils/sortDependencies.js.map +1 -0
- package/dist/utils/viteConfigRender.d.ts +19 -0
- package/dist/utils/viteConfigRender.d.ts.map +1 -0
- package/dist/utils/viteConfigRender.js +180 -0
- package/dist/utils/viteConfigRender.js.map +1 -0
- package/package.json +93 -0
- package/templates/common/base/.env +7 -0
- package/templates/common/base/.env.development +5 -0
- package/templates/common/base/.env.production +5 -0
- package/templates/common/base/package.json +56 -0
- package/templates/common/base/pnpm-workspace.yaml +37 -0
- package/templates/common/base/scripts/build.mts +31 -0
- package/templates/common/base/src/apis/index.ts +8 -0
- package/templates/common/base/src/apis/request.ts +43 -0
- package/templates/common/base/src/apis/services/example.ts +40 -0
- package/templates/common/base/src/apis/services/user.ts +23 -0
- package/templates/common/base/src/apis/types/common.ts +28 -0
- package/templates/common/base/src/apis/types/example.ts +18 -0
- package/templates/common/base/src/apis/types/index.ts +7 -0
- package/templates/common/base/src/apis/types/user.ts +24 -0
- package/templates/common/base/src/assets/fonts/index.css +7 -0
- package/templates/common/base/src/assets/styles/base.scss +72 -0
- package/templates/common/base/src/assets/styles/custom.scss +7 -0
- package/templates/common/base/src/assets/styles/tailwind.scss +6 -0
- package/templates/common/base/src/constants/index.ts +29 -0
- package/templates/common/base/src/locales/lang/en.ts +30 -0
- package/templates/common/base/src/locales/lang/es.ts +30 -0
- package/templates/common/base/src/locales/lang/zh.ts +30 -0
- package/templates/common/base/src/utils/index.ts +83 -0
- package/templates/common/features/husky/.cz-config.cjs +35 -0
- package/templates/common/features/husky/.husky/commit-msg +9 -0
- package/templates/common/features/husky/.husky/install.mjs +6 -0
- package/templates/common/features/husky/.husky/pre-commit +4 -0
- package/templates/common/features/husky/commitlint.config.ts +32 -0
- package/templates/common/features/husky/package.json +28 -0
- package/templates/common/features/husky/pnpm-workspace.yaml +9 -0
- package/templates/react/base/env.d.ts +19 -0
- package/templates/react/base/index.html +14 -0
- package/templates/react/base/package.json +15 -0
- package/templates/react/base/pnpm-workspace.yaml +9 -0
- package/templates/react/base/src/App.tsx +18 -0
- package/templates/react/base/src/assets/styles/main.scss +8 -0
- package/templates/react/base/src/main.tsx.ejs +39 -0
- package/templates/react/base/src/pages/about/index.tsx +14 -0
- package/templates/react/base/src/pages/home/index.tsx +14 -0
- package/templates/react/base/src/router/index.tsx.ejs +28 -0
- package/templates/react/base/src/stores/user.ts +39 -0
- package/templates/react/base/tsconfig.app.json +17 -0
- package/templates/react/base/tsconfig.base.json +23 -0
- package/templates/react/base/tsconfig.json +12 -0
- package/templates/react/base/tsconfig.node.json +15 -0
- package/templates/react/base/vite.config.ts +52 -0
- package/templates/react/features/ant-design/package.json +7 -0
- package/templates/react/features/ant-design/pnpm-workspace.yaml +5 -0
- package/templates/react/features/eslint/eslint.config.ts +12 -0
- package/templates/react/features/eslint/package.json +7 -0
- package/templates/react/features/eslint/pnpm-workspace.yaml +6 -0
- package/templates/react/features/i18n/package.json +7 -0
- package/templates/react/features/i18n/pnpm-workspace.yaml +5 -0
- package/templates/react/features/i18n/src/locales/index.ts +20 -0
- package/templates/react/features/manualRoutes/src/router/routes.tsx +21 -0
- package/templates/react/features/pageRoutes/package.json +6 -0
- package/templates/react/features/pageRoutes/pnpm-workspace.yaml +4 -0
- package/templates/react/features/pageRoutes/vite.config.data.ts +10 -0
- package/templates/react/features/router/package.json +5 -0
- package/templates/react/features/router/pnpm-workspace.yaml +3 -0
- package/templates/react/features/sentry/package.json +7 -0
- package/templates/react/features/sentry/pnpm-workspace.yaml +5 -0
- package/templates/react/features/sentry/src/utils/sentry.ts +30 -0
- package/templates/react/features/sentry/vite.config.data.ts +23 -0
- package/templates/react/features/zustand/package.json +5 -0
- package/templates/react/features/zustand/pnpm-workspace.yaml +3 -0
- package/templates/react/features/zustand/src/stores/user.ts +19 -0
- package/templates/react/features/zustand/src/types/stores.ts +15 -0
- package/templates/vue/base/env.d.ts +27 -0
- package/templates/vue/base/index.html +14 -0
- package/templates/vue/base/package.json +13 -0
- package/templates/vue/base/pnpm-workspace.yaml +6 -0
- package/templates/vue/base/src/App.vue +13 -0
- package/templates/vue/base/src/assets/styles/element/index.scss +27 -0
- package/templates/vue/base/src/assets/styles/main.scss +9 -0
- package/templates/vue/base/src/components/SubMenu/index.ts +9 -0
- package/templates/vue/base/src/components/SubMenu/src/_types/index.ts +6 -0
- package/templates/vue/base/src/components/SubMenu/src/_types/props.ts +11 -0
- package/templates/vue/base/src/components/SubMenu/src/index.vue +24 -0
- package/templates/vue/base/src/directives/index.ts +36 -0
- package/templates/vue/base/src/layouts/AntDesign.vue +86 -0
- package/templates/vue/base/src/layouts/element.vue +81 -0
- package/templates/vue/base/src/layouts/index.ts +7 -0
- package/templates/vue/base/src/main.ts.ejs +100 -0
- package/templates/vue/base/src/pages/about/index.vue +31 -0
- package/templates/vue/base/src/pages/home/index.vue +31 -0
- package/templates/vue/base/src/router/index.ts.ejs +39 -0
- package/templates/vue/base/src/stores/index.ts +16 -0
- package/templates/vue/base/src/stores/modules/system.ts +52 -0
- package/templates/vue/base/src/stores/modules/user.ts +48 -0
- package/templates/vue/base/tsconfig.app.json +17 -0
- package/templates/vue/base/tsconfig.base.json +23 -0
- package/templates/vue/base/tsconfig.json +12 -0
- package/templates/vue/base/tsconfig.node.json +15 -0
- package/templates/vue/base/vite.config.ts +53 -0
- package/templates/vue/features/ant-design-vue/package.json +7 -0
- package/templates/vue/features/ant-design-vue/pnpm-workspace.yaml +5 -0
- package/templates/vue/features/element-plus/package.json +7 -0
- package/templates/vue/features/element-plus/pnpm-workspace.yaml +5 -0
- package/templates/vue/features/element-plus/vite.config.data.ts +15 -0
- package/templates/vue/features/eslint/eslint.config.ts +12 -0
- package/templates/vue/features/eslint/package.json +7 -0
- package/templates/vue/features/eslint/pnpm-workspace.yaml +6 -0
- package/templates/vue/features/i18n/package.json +5 -0
- package/templates/vue/features/i18n/pnpm-workspace.yaml +3 -0
- package/templates/vue/features/i18n/src/locales/index.ts +16 -0
- package/templates/vue/features/manualRoutes/src/router/layout.vue +10 -0
- package/templates/vue/features/manualRoutes/src/router/routes.ts +27 -0
- package/templates/vue/features/pageRoutes/package.json +5 -0
- package/templates/vue/features/pageRoutes/pnpm-workspace.yaml +4 -0
- package/templates/vue/features/pageRoutes/vite.config.data.ts +9 -0
- package/templates/vue/features/pinia/package.json +6 -0
- package/templates/vue/features/pinia/pnpm-workspace.yaml +4 -0
- package/templates/vue/features/pinia/src/stores/index.ts +8 -0
- package/templates/vue/features/pinia/src/stores/user.ts +36 -0
- package/templates/vue/features/qiankun/package.json +5 -0
- package/templates/vue/features/qiankun/pnpm-workspace.yaml +3 -0
- package/templates/vue/features/qiankun/src/qiankun/index.ts +56 -0
- package/templates/vue/features/router/package.json +5 -0
- package/templates/vue/features/router/pnpm-workspace.yaml +3 -0
- package/templates/vue/features/sentry/package.json +6 -0
- package/templates/vue/features/sentry/pnpm-workspace.yaml +4 -0
- package/templates/vue/features/sentry/src/utils/sentry.ts +33 -0
- package/templates/vue/features/sentry/vite.config.data.ts +23 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* SubMenu 子菜单组件
|
|
4
|
+
* 递归渲染菜单
|
|
5
|
+
*/
|
|
6
|
+
import type { SubMenuProps } from './_types';
|
|
7
|
+
|
|
8
|
+
defineProps<SubMenuProps>();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<template v-for="item in menuList" :key="item.path">
|
|
13
|
+
<el-sub-menu v-if="item.children?.length" :index="item.path">
|
|
14
|
+
<template #title>
|
|
15
|
+
<span>{{ item.meta?.title }}</span>
|
|
16
|
+
</template>
|
|
17
|
+
<SubMenu :menu-list="item.children" />
|
|
18
|
+
</el-sub-menu>
|
|
19
|
+
<el-menu-item v-else :index="item.path">
|
|
20
|
+
<span>{{ item.meta?.title }}</span>
|
|
21
|
+
</el-menu-item>
|
|
22
|
+
</template>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
@@ -0,0 +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
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Ant Design Vue 布局组件
|
|
4
|
+
*/
|
|
5
|
+
import { ref } from 'vue';
|
|
6
|
+
|
|
7
|
+
const sidebarCollapsed = ref(false);
|
|
8
|
+
|
|
9
|
+
function toggleSidebar(): void {
|
|
10
|
+
sidebarCollapsed.value = !sidebarCollapsed.value;
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<a-layout class="layout-container">
|
|
16
|
+
<a-layout-sider
|
|
17
|
+
v-model:collapsed="sidebarCollapsed"
|
|
18
|
+
collapsible
|
|
19
|
+
:trigger="null"
|
|
20
|
+
class="layout-sider"
|
|
21
|
+
>
|
|
22
|
+
<div class="logo">
|
|
23
|
+
<span v-if="!sidebarCollapsed">Logo</span>
|
|
24
|
+
</div>
|
|
25
|
+
<a-menu theme="dark" mode="inline" :default-selected-keys="['1']">
|
|
26
|
+
<a-menu-item key="1">
|
|
27
|
+
<span>首页</span>
|
|
28
|
+
</a-menu-item>
|
|
29
|
+
<a-menu-item key="2">
|
|
30
|
+
<span>关于</span>
|
|
31
|
+
</a-menu-item>
|
|
32
|
+
</a-menu>
|
|
33
|
+
</a-layout-sider>
|
|
34
|
+
<a-layout>
|
|
35
|
+
<a-layout-header class="layout-header">
|
|
36
|
+
<a-button @click="toggleSidebar">
|
|
37
|
+
{{ sidebarCollapsed ? '展开' : '折叠' }}
|
|
38
|
+
</a-button>
|
|
39
|
+
</a-layout-header>
|
|
40
|
+
<a-layout-content class="layout-content">
|
|
41
|
+
<slot />
|
|
42
|
+
</a-layout-content>
|
|
43
|
+
</a-layout>
|
|
44
|
+
</a-layout>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<style scoped lang="scss">
|
|
48
|
+
.layout-container {
|
|
49
|
+
height: 100vh;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.layout-sider {
|
|
53
|
+
overflow: auto;
|
|
54
|
+
height: 100vh;
|
|
55
|
+
position: fixed;
|
|
56
|
+
left: 0;
|
|
57
|
+
top: 0;
|
|
58
|
+
bottom: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.logo {
|
|
62
|
+
height: 32px;
|
|
63
|
+
margin: 16px;
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
color: #fff;
|
|
68
|
+
font-size: 18px;
|
|
69
|
+
font-weight: bold;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.layout-header {
|
|
73
|
+
background: #fff;
|
|
74
|
+
padding: 0 16px;
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.layout-content {
|
|
80
|
+
margin: 24px 16px;
|
|
81
|
+
padding: 24px;
|
|
82
|
+
background: #fff;
|
|
83
|
+
min-height: 280px;
|
|
84
|
+
}
|
|
85
|
+
</style>
|
|
86
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Element Plus 布局组件
|
|
4
|
+
*/
|
|
5
|
+
import { ref } from 'vue';
|
|
6
|
+
|
|
7
|
+
const sidebarCollapsed = ref(false);
|
|
8
|
+
|
|
9
|
+
function toggleSidebar(): void {
|
|
10
|
+
sidebarCollapsed.value = !sidebarCollapsed.value;
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<el-container class="layout-container">
|
|
16
|
+
<el-aside :width="sidebarCollapsed ? '64px' : '200px'" class="layout-aside">
|
|
17
|
+
<div class="logo">
|
|
18
|
+
<span v-if="!sidebarCollapsed">Logo</span>
|
|
19
|
+
</div>
|
|
20
|
+
<el-menu
|
|
21
|
+
:collapse="sidebarCollapsed"
|
|
22
|
+
default-active="1"
|
|
23
|
+
class="layout-menu"
|
|
24
|
+
>
|
|
25
|
+
<el-menu-item index="1">
|
|
26
|
+
<template #title>首页</template>
|
|
27
|
+
</el-menu-item>
|
|
28
|
+
<el-menu-item index="2">
|
|
29
|
+
<template #title>关于</template>
|
|
30
|
+
</el-menu-item>
|
|
31
|
+
</el-menu>
|
|
32
|
+
</el-aside>
|
|
33
|
+
<el-container>
|
|
34
|
+
<el-header class="layout-header">
|
|
35
|
+
<el-button @click="toggleSidebar">
|
|
36
|
+
{{ sidebarCollapsed ? '展开' : '折叠' }}
|
|
37
|
+
</el-button>
|
|
38
|
+
</el-header>
|
|
39
|
+
<el-main class="layout-main">
|
|
40
|
+
<slot />
|
|
41
|
+
</el-main>
|
|
42
|
+
</el-container>
|
|
43
|
+
</el-container>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<style scoped lang="scss">
|
|
47
|
+
.layout-container {
|
|
48
|
+
height: 100vh;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.layout-aside {
|
|
52
|
+
background-color: #304156;
|
|
53
|
+
transition: width 0.3s;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.logo {
|
|
57
|
+
height: 60px;
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
color: #fff;
|
|
62
|
+
font-size: 20px;
|
|
63
|
+
font-weight: bold;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.layout-menu {
|
|
67
|
+
border-right: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.layout-header {
|
|
71
|
+
background-color: #fff;
|
|
72
|
+
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.layout-main {
|
|
78
|
+
background-color: #f0f2f5;
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
81
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 应用入口文件
|
|
3
|
+
* 初始化 Vue 应用并挂载到 DOM
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
<% if (qiankun) { -%>
|
|
7
|
+
import type { QiankunProps } from 'vite-plugin-qiankun/dist/helper'
|
|
8
|
+
import { qiankunWindow, renderWithQiankun } from 'vite-plugin-qiankun/dist/helper'
|
|
9
|
+
<% } -%>
|
|
10
|
+
import { createApp } from 'vue'
|
|
11
|
+
import directives from '@/directives'
|
|
12
|
+
<% if (i18n) { -%>
|
|
13
|
+
import i18n from '@/locales'
|
|
14
|
+
<% } -%>
|
|
15
|
+
<% if (sentry) { -%>
|
|
16
|
+
import { initSentry } from '@/utils/sentry'
|
|
17
|
+
<% } -%>
|
|
18
|
+
import { store } from '@/stores'
|
|
19
|
+
import App from './App.vue'
|
|
20
|
+
import getRouter from './router'
|
|
21
|
+
|
|
22
|
+
// 导入样式文件
|
|
23
|
+
<% if (uiLibrary === 'element-plus') { -%>
|
|
24
|
+
import '@/assets/styles/element/index.scss'
|
|
25
|
+
<% } -%>
|
|
26
|
+
import '@/assets/styles/main.scss'
|
|
27
|
+
import '@/assets/fonts/index.css'
|
|
28
|
+
|
|
29
|
+
<% if (qiankun) { -%>
|
|
30
|
+
let app: ReturnType<typeof createApp> | null = null
|
|
31
|
+
|
|
32
|
+
async function render(props: QiankunProps = {}): Promise<void> {
|
|
33
|
+
const { container } = props
|
|
34
|
+
app = createApp(App)
|
|
35
|
+
|
|
36
|
+
directives(app)
|
|
37
|
+
const router = getRouter(props)
|
|
38
|
+
|
|
39
|
+
<% if (sentry) { -%>
|
|
40
|
+
initSentry(app, router, {
|
|
41
|
+
dsn: import.meta.env.VITE_SENTRY_DSN,
|
|
42
|
+
environment: import.meta.env.MODE,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
<% } -%>
|
|
46
|
+
app.use(store)
|
|
47
|
+
<% if (i18n) { -%>
|
|
48
|
+
app.use(i18n)
|
|
49
|
+
<% } -%>
|
|
50
|
+
app.use(router)
|
|
51
|
+
app.config.warnHandler = () => null
|
|
52
|
+
|
|
53
|
+
if (container) {
|
|
54
|
+
const root = container.querySelector('#app')
|
|
55
|
+
app.mount(root)
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
app.mount('#app')
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
|
|
63
|
+
render({})
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
renderWithQiankun({
|
|
67
|
+
async mount(props: QiankunProps) {
|
|
68
|
+
await render(props)
|
|
69
|
+
},
|
|
70
|
+
bootstrap() {},
|
|
71
|
+
unmount() {
|
|
72
|
+
app?.unmount()
|
|
73
|
+
app = null
|
|
74
|
+
},
|
|
75
|
+
update() {},
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
<% } else { -%>
|
|
79
|
+
const app = createApp(App)
|
|
80
|
+
|
|
81
|
+
directives(app)
|
|
82
|
+
const router = getRouter({})
|
|
83
|
+
|
|
84
|
+
<% if (sentry) { -%>
|
|
85
|
+
initSentry(app, router, {
|
|
86
|
+
dsn: import.meta.env.VITE_SENTRY_DSN,
|
|
87
|
+
environment: import.meta.env.MODE,
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
<% } -%>
|
|
91
|
+
app.use(store)
|
|
92
|
+
<% if (i18n) { -%>
|
|
93
|
+
app.use(i18n)
|
|
94
|
+
<% } -%>
|
|
95
|
+
app.use(router)
|
|
96
|
+
app.config.warnHandler = () => null
|
|
97
|
+
|
|
98
|
+
app.mount('#app')
|
|
99
|
+
<% } -%>
|
|
100
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* 关于页面
|
|
4
|
+
*/
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<div class="about-page">
|
|
9
|
+
<h1>关于</h1>
|
|
10
|
+
<p>这是关于页面</p>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<style scoped lang="scss">
|
|
15
|
+
.about-page {
|
|
16
|
+
padding: 24px;
|
|
17
|
+
text-align: center;
|
|
18
|
+
|
|
19
|
+
h1 {
|
|
20
|
+
font-size: 32px;
|
|
21
|
+
margin-bottom: 16px;
|
|
22
|
+
color: #333;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
p {
|
|
26
|
+
font-size: 16px;
|
|
27
|
+
color: #666;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
</style>
|
|
31
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* 首页
|
|
4
|
+
*/
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<div class="home-page">
|
|
9
|
+
<h1>欢迎使用 Vue Template</h1>
|
|
10
|
+
<p>这是一个基于 Vue 3 + Vite + TypeScript 的项目模板</p>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<style scoped lang="scss">
|
|
15
|
+
.home-page {
|
|
16
|
+
padding: 24px;
|
|
17
|
+
text-align: center;
|
|
18
|
+
|
|
19
|
+
h1 {
|
|
20
|
+
font-size: 32px;
|
|
21
|
+
margin-bottom: 16px;
|
|
22
|
+
color: #333;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
p {
|
|
26
|
+
font-size: 16px;
|
|
27
|
+
color: #666;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
</style>
|
|
31
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 路由配置
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
<% if (qiankun) { -%>
|
|
6
|
+
import type { QiankunProps } from 'vite-plugin-qiankun/dist/helper'
|
|
7
|
+
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
|
|
8
|
+
<% } -%>
|
|
9
|
+
import { createRouter, createWebHistory } from 'vue-router'
|
|
10
|
+
<% if (routeMode === 'file-system') { -%>
|
|
11
|
+
import routes from '~pages'
|
|
12
|
+
<% } else { -%>
|
|
13
|
+
import { routes } from './routes'
|
|
14
|
+
<% } -%>
|
|
15
|
+
|
|
16
|
+
<% if (qiankun) { -%>
|
|
17
|
+
export default function getRouter(props: QiankunProps = {}) {
|
|
18
|
+
const router = createRouter({
|
|
19
|
+
history: createWebHistory(
|
|
20
|
+
qiankunWindow.__POWERED_BY_QIANKUN__
|
|
21
|
+
? '/sub-app/'
|
|
22
|
+
: import.meta.env.BASE_URL,
|
|
23
|
+
),
|
|
24
|
+
routes,
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
return router
|
|
28
|
+
}
|
|
29
|
+
<% } else { -%>
|
|
30
|
+
export default function getRouter(_props: Record<string, unknown> = {}) {
|
|
31
|
+
const router = createRouter({
|
|
32
|
+
history: createWebHistory(import.meta.env.BASE_URL),
|
|
33
|
+
routes,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return router
|
|
37
|
+
}
|
|
38
|
+
<% } -%>
|
|
39
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
// 导出 store 模块
|
|
14
|
+
export * from './modules/user';
|
|
15
|
+
export * from './modules/system';
|
|
16
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
function setTheme(value: ThemeType): void {
|
|
24
|
+
theme.value = value;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** 设置语言 */
|
|
28
|
+
function setLanguage(value: string): void {
|
|
29
|
+
language.value = value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** 切换侧边栏 */
|
|
33
|
+
function toggleSidebar(): void {
|
|
34
|
+
sidebarCollapsed.value = !sidebarCollapsed.value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
theme,
|
|
39
|
+
language,
|
|
40
|
+
sidebarCollapsed,
|
|
41
|
+
setTheme,
|
|
42
|
+
setLanguage,
|
|
43
|
+
toggleSidebar,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
persist: {
|
|
48
|
+
pick: ['theme', 'language', 'sidebarCollapsed'],
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
function setUserInfo(info: UserInfo | null): void {
|
|
20
|
+
userInfo.value = info;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 设置 token */
|
|
24
|
+
function setToken(value: string): void {
|
|
25
|
+
token.value = value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 清除用户信息 */
|
|
29
|
+
function clearUser(): void {
|
|
30
|
+
userInfo.value = null;
|
|
31
|
+
token.value = '';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
userInfo,
|
|
36
|
+
token,
|
|
37
|
+
setUserInfo,
|
|
38
|
+
setToken,
|
|
39
|
+
clearUser,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
persist: {
|
|
44
|
+
pick: ['token'],
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"composite": true,
|
|
5
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
6
|
+
"baseUrl": ".",
|
|
7
|
+
"paths": {
|
|
8
|
+
"@/*": ["./src/*"]
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"env.d.ts",
|
|
13
|
+
"src/**/*",
|
|
14
|
+
"src/**/*.vue"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"allowImportingTsExtensions": true,
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"moduleDetection": "force",
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"jsx": "preserve",
|
|
14
|
+
"strict": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"noFallthroughCasesInSwitch": true,
|
|
18
|
+
"noUncheckedSideEffectImports": true,
|
|
19
|
+
"resolveJsonModule": true,
|
|
20
|
+
"esModuleInterop": true
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"composite": true,
|
|
5
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
6
|
+
"types": ["node"]
|
|
7
|
+
},
|
|
8
|
+
"include": [
|
|
9
|
+
"vite.config.*",
|
|
10
|
+
"eslint.config.*",
|
|
11
|
+
"commitlint.config.*",
|
|
12
|
+
"scripts/**/*"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite 配置文件
|
|
3
|
+
* 基于 @moluoxixi/vite-config 的配置
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import path from 'node:path'
|
|
7
|
+
import process from 'node:process'
|
|
8
|
+
import cssModuleGlobalRootPlugin from '@moluoxixi/css-module-global-root-plugin'
|
|
9
|
+
import { ViteConfig, wrapperEnv } from '@moluoxixi/vite-config'
|
|
10
|
+
import { loadEnv } from 'vite'
|
|
11
|
+
|
|
12
|
+
export default ViteConfig(
|
|
13
|
+
({ mode }) => {
|
|
14
|
+
const env = loadEnv(mode!, process.cwd())
|
|
15
|
+
const viteEnv = wrapperEnv(env)
|
|
16
|
+
const rootPath = path.resolve()
|
|
17
|
+
const appCode = viteEnv.VITE_APP_CODE
|
|
18
|
+
const appTitle = viteEnv.VITE_APP_TITLE
|
|
19
|
+
const port = viteEnv.VITE_APP_PORT
|
|
20
|
+
return {
|
|
21
|
+
rootPath,
|
|
22
|
+
appTitle,
|
|
23
|
+
appCode,
|
|
24
|
+
port,
|
|
25
|
+
vue: true,
|
|
26
|
+
autoComponent: true,
|
|
27
|
+
viteConfig: {
|
|
28
|
+
plugins: [],
|
|
29
|
+
server: {
|
|
30
|
+
proxy: {
|
|
31
|
+
'/api': {
|
|
32
|
+
changeOrigin: true,
|
|
33
|
+
target: 'http://localhost:3000',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
css: {
|
|
38
|
+
postcss: {
|
|
39
|
+
plugins: [
|
|
40
|
+
cssModuleGlobalRootPlugin,
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
preprocessorOptions: {
|
|
44
|
+
scss: {
|
|
45
|
+
silenceDeprecations: ['legacy-js-api'],
|
|
46
|
+
api: 'modern-compiler',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
)
|