@moluoxixi/create-app 2.0.412 → 2.0.414
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 +57 -1
- package/dist/commands/create.js +1 -1
- package/dist/core/feature.d.ts +80 -0
- package/dist/core/feature.js +252 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +6 -0
- package/dist/core/prompts.d.ts +17 -0
- package/dist/core/prompts.js +235 -0
- package/dist/core/template.d.ts +22 -0
- package/dist/core/template.js +177 -0
- package/dist/generators/index.d.ts +0 -2
- package/dist/generators/index.js +0 -2
- package/dist/generators/project.d.ts +1 -0
- package/dist/generators/project.js +66 -13
- package/dist/generators/react.d.ts +5 -5
- package/dist/generators/react.js +6 -9
- package/dist/generators/vue.d.ts +5 -5
- package/dist/generators/vue.js +6 -9
- package/dist/test.d.ts +0 -4
- package/dist/test.js +32 -17
- package/dist/types/index.d.ts +25 -26
- package/dist/types/index.js +2 -3
- package/dist/utils/featureMapping.js +6 -3
- package/dist/utils/generateFrameworkProject.d.ts +10 -20
- package/dist/utils/generateFrameworkProject.js +32 -127
- package/dist/utils/index.d.ts +1 -6
- package/dist/utils/index.js +1 -6
- package/dist/utils/prompts.js +7 -3
- package/package.json +2 -2
- package/templates/common/base/package.json +3 -1
- package/templates/common/base/vite/index.ts +53 -0
- package/templates/common/base/vite.config.ts +56 -0
- package/templates/common/features/husky/node_modules/.bin/tsc +17 -0
- package/templates/common/features/husky/node_modules/.bin/tsc.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/tsc.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/tsserver +17 -0
- package/templates/common/features/husky/node_modules/.bin/tsserver.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/tsserver.ps1 +41 -0
- package/templates/react/base/src/main/index.ts +34 -0
- package/templates/react/base/src/main.tsx +34 -0
- package/templates/react/base/tsconfig.app.json +1 -0
- package/templates/react/base/tsconfig.node.json +1 -0
- package/templates/react/features/ant-design/package.json +2 -1
- package/templates/react/features/ant-design/src/main/features/ant-design.ts +21 -0
- package/templates/react/features/i18n/package.json +2 -1
- package/templates/react/features/i18n/src/main/features/i18n.ts +19 -0
- package/templates/react/features/manualRoutes/package.json +1 -0
- package/templates/react/features/sentry/package.json +2 -1
- package/templates/react/features/sentry/src/main/features/sentry.ts +20 -0
- package/templates/react/features/sentry/vite/features/sentry.ts +39 -0
- package/templates/react/features/zustand/src/apis/types/user.ts +39 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/jiti +17 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/jiti.CMD +12 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/jiti.ps1 +41 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/parser +17 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/parser.CMD +12 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/parser.ps1 +41 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/rollup +17 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/rollup.CMD +12 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/rollup.ps1 +41 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/sass +17 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/sass.CMD +12 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/sass.ps1 +41 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/terser +17 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/terser.CMD +12 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/terser.ps1 +41 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsc +17 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsc.CMD +12 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsc.ps1 +41 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsserver +17 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsserver.CMD +12 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsserver.ps1 +41 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsx +17 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsx.CMD +12 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsx.ps1 +41 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/vite +17 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/vite.CMD +12 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/vite.ps1 +41 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/yaml +17 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/yaml.CMD +12 -0
- package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/yaml.ps1 +41 -0
- package/templates/react/micro-frontends/qiankun/base/package.json +5 -2
- package/templates/react/micro-frontends/qiankun/base/src/main/index.ts +34 -0
- package/templates/react/micro-frontends/qiankun/base/src/{main.tsx.ejs → main.tsx} +13 -27
- package/templates/react/micro-frontends/qiankun/base/vite/index.ts +53 -0
- package/templates/react/micro-frontends/qiankun/base/vite.config.ts +58 -0
- package/templates/vue/base/src/main/index.ts +36 -0
- package/templates/vue/base/src/main.ts +34 -0
- package/templates/vue/base/tsconfig.app.json +2 -1
- package/templates/vue/base/tsconfig.node.json +2 -1
- package/templates/vue/features/ant-design-vue/package.json +3 -1
- package/templates/vue/features/ant-design-vue/src/main/features/ant-design-vue.ts +18 -0
- package/templates/vue/features/element-plus/package.json +5 -1
- package/templates/vue/features/element-plus/src/main/features/element-plus.ts +23 -0
- package/templates/vue/features/element-plus/src/stores/index.ts +6 -0
- package/templates/vue/features/element-plus/src/stores/modules/system.ts +51 -0
- package/templates/vue/features/element-plus/vite/features/element-plus.ts +35 -0
- package/templates/vue/features/i18n/package.json +3 -1
- package/templates/vue/features/i18n/src/main/features/i18n.ts +19 -0
- package/templates/vue/features/manualRoutes/package.json +7 -1
- package/templates/vue/features/manualRoutes/src/layouts/index.ts +26 -0
- 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/pageRoutes/package.json +7 -1
- package/templates/vue/features/pageRoutes/src/layouts/index.ts +26 -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/pinia/package.json +3 -1
- package/templates/vue/features/pinia/src/main/features/pinia.ts +19 -0
- package/templates/vue/features/sentry/package.json +4 -2
- package/templates/vue/features/sentry/src/main/features/sentry.ts +22 -0
- package/templates/vue/features/sentry/vite/features/sentry.ts +39 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/jiti +17 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/jiti.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/jiti.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/parser +17 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/parser.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/parser.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/rollup +17 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/rollup.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/rollup.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/sass +17 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/sass.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/sass.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/terser +17 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/terser.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/terser.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsc +17 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsc.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsc.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsserver +17 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsserver.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsserver.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsx +17 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsx.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsx.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/vite +17 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/vite.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/vite.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/yaml +17 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/yaml.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/yaml.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/base/package.json +5 -2
- package/templates/vue/micro-frontends/qiankun/base/src/main/index.ts +36 -0
- package/templates/vue/micro-frontends/qiankun/base/src/{main.ts.ejs → main.ts} +11 -28
- package/templates/vue/micro-frontends/qiankun/base/vite/index.ts +53 -0
- package/templates/vue/micro-frontends/qiankun/base/vite.config.ts +59 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/jiti +17 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/jiti.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/jiti.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/sass +17 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/sass.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/sass.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/terser +17 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/terser.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/terser.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsc +17 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsc.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsc.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsserver +17 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsserver.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsserver.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsx +17 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsx.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsx.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/vite +17 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/vite.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/vite.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/yaml +17 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/yaml.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/yaml.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/package.json +10 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/src/components/SubMenu/index.ts +8 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/src/components/SubMenu/src/_types/index.ts +1 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/src/components/SubMenu/src/_types/props.ts +16 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/src/components/SubMenu/src/index.vue +60 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/src/main/features/element-plus.ts +24 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/src/stores/index.ts +6 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/src/stores/modules/system.ts +51 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/vite/features/element-plus.ts +35 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/package.json +6 -1
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/package.json +6 -1
- package/templates/common/base/vite.config.ts.ejs +0 -85
- package/templates/react/base/src/main.tsx.ejs +0 -56
- package/templates/react/micro-frontends/qiankun/base/vite.config.ts.ejs +0 -89
- package/templates/vue/base/src/main.ts.ejs +0 -61
- package/templates/vue/micro-frontends/qiankun/base/vite.config.ts.ejs +0 -89
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import cssModuleGlobalRootPlugin from '@moluoxixi/css-module-global-root-plugin'
|
|
3
|
+
import { ViteConfig, wrapperEnv } from '@moluoxixi/vite-config'
|
|
4
|
+
import { loadEnv, mergeConfig } from 'vite'
|
|
5
|
+
import process from 'node:process'
|
|
6
|
+
import { loadFeatureConfigs } from './vite/index.ts'
|
|
7
|
+
|
|
8
|
+
const config: ReturnType<typeof ViteConfig> = ViteConfig(({ mode }) => {
|
|
9
|
+
const env = loadEnv(mode!, process.cwd())
|
|
10
|
+
const viteEnv = wrapperEnv(env)
|
|
11
|
+
const rootPath = path.resolve()
|
|
12
|
+
const appCode = viteEnv.VITE_APP_CODE
|
|
13
|
+
const appTitle = viteEnv.VITE_APP_TITLE
|
|
14
|
+
const port = viteEnv.VITE_APP_PORT
|
|
15
|
+
|
|
16
|
+
// 加载所有 feature 配置
|
|
17
|
+
const featureConfig = loadFeatureConfigs({ viteEnv, mode: mode!, appCode })
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
rootPath,
|
|
21
|
+
appTitle,
|
|
22
|
+
appCode,
|
|
23
|
+
port,
|
|
24
|
+
react: true,
|
|
25
|
+
pageRoutes: true,
|
|
26
|
+
viteConfig: mergeConfig(
|
|
27
|
+
{
|
|
28
|
+
server: {
|
|
29
|
+
proxy: {
|
|
30
|
+
'/api': {
|
|
31
|
+
changeOrigin: true,
|
|
32
|
+
target: 'http://localhost:3000',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
headers: {
|
|
36
|
+
'Access-Control-Allow-Origin': '*',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
css: {
|
|
40
|
+
preprocessorOptions: {
|
|
41
|
+
scss: {
|
|
42
|
+
silenceDeprecations: ['legacy-js-api'],
|
|
43
|
+
api: 'modern-compiler',
|
|
44
|
+
},
|
|
45
|
+
postcss: {
|
|
46
|
+
plugins: [
|
|
47
|
+
cssModuleGlobalRootPlugin() as any,
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
featureConfig,
|
|
54
|
+
),
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
export default config
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature 设置模块
|
|
3
|
+
* 使用 Vite 的 glob 导入自动发现并加载所有 feature 模块
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { App } from 'vue'
|
|
7
|
+
import type { Router } from 'vue-router'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Feature 模块接口
|
|
11
|
+
*/
|
|
12
|
+
interface FeatureModule {
|
|
13
|
+
/** 初始化 feature 的设置函数 */
|
|
14
|
+
setup?: (app: App, router: Router) => void | Promise<void>
|
|
15
|
+
/** 执行顺序(数字越小越先执行) */
|
|
16
|
+
order?: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 自动发现所有 feature 模块
|
|
20
|
+
const featureModules = import.meta.glob('./features/*.ts', { eager: true })
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 设置所有 features
|
|
24
|
+
* @param app - Vue 应用实例
|
|
25
|
+
* @param router - Vue Router 实例
|
|
26
|
+
*/
|
|
27
|
+
export async function setupFeatures(app: App, router: Router): Promise<void> {
|
|
28
|
+
const modules = Object.values(featureModules) as FeatureModule[]
|
|
29
|
+
|
|
30
|
+
// 按顺序排序(默认 100)
|
|
31
|
+
modules.sort((a, b) => (a.order ?? 100) - (b.order ?? 100))
|
|
32
|
+
|
|
33
|
+
for (const mod of modules) {
|
|
34
|
+
await mod.setup?.(app, router)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application entry file - Standard mode
|
|
3
|
+
* Initialize Vue application and mount to DOM
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createApp } from 'vue'
|
|
7
|
+
import directives from '@/directives'
|
|
8
|
+
import App from './App.vue'
|
|
9
|
+
import getRouter from './router'
|
|
10
|
+
import { setupFeatures } from './main/index'
|
|
11
|
+
|
|
12
|
+
// Import styles
|
|
13
|
+
import '@/assets/styles/main.scss'
|
|
14
|
+
import '@/assets/fonts/index.css'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Initialize and render application
|
|
18
|
+
*/
|
|
19
|
+
async function initApp(): Promise<void> {
|
|
20
|
+
const app = createApp(App)
|
|
21
|
+
const router = getRouter()
|
|
22
|
+
|
|
23
|
+
directives(app)
|
|
24
|
+
|
|
25
|
+
// Setup all features (pinia, i18n, sentry, etc.)
|
|
26
|
+
await setupFeatures(app, router)
|
|
27
|
+
|
|
28
|
+
app.use(router)
|
|
29
|
+
app.config.warnHandler = () => null
|
|
30
|
+
|
|
31
|
+
app.mount('#app')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
initApp()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ant Design Vue UI 组件库 feature 设置
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { App } from 'vue'
|
|
6
|
+
import type { Router } from 'vue-router'
|
|
7
|
+
|
|
8
|
+
/** 执行顺序 - 样式应该尽早加载 */
|
|
9
|
+
export const order = 5
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 设置 Ant Design Vue
|
|
13
|
+
* @param _app - Vue 应用实例(未使用,自动导入)
|
|
14
|
+
* @param _router - Vue Router 实例(未使用)
|
|
15
|
+
*/
|
|
16
|
+
export function setup(_app: App, _router: Router): void {
|
|
17
|
+
// Ant Design Vue 通过 unplugin-vue-components 自动导入
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element Plus UI 组件库 feature 设置
|
|
3
|
+
* 导入 Element Plus 样式
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { App } from 'vue'
|
|
7
|
+
import type { Router } from 'vue-router'
|
|
8
|
+
|
|
9
|
+
// 导入 Element Plus 样式
|
|
10
|
+
import '@/assets/styles/element/index.scss'
|
|
11
|
+
|
|
12
|
+
/** 执行顺序 - 样式应该尽早加载 */
|
|
13
|
+
export const order = 5
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 设置 Element Plus
|
|
17
|
+
* @param _app - Vue 应用实例(未使用,样式已导入)
|
|
18
|
+
* @param _router - Vue Router 实例(未使用)
|
|
19
|
+
*/
|
|
20
|
+
export function setup(_app: App, _router: Router): void {
|
|
21
|
+
// Element Plus 通过 unplugin-vue-components 自动导入
|
|
22
|
+
// 只需要导入样式
|
|
23
|
+
}
|
|
@@ -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,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element Plus Vite 配置
|
|
3
|
+
* 为 Element Plus 添加 SCSS 命名空间配置
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Vite feature 配置上下文
|
|
8
|
+
*/
|
|
9
|
+
interface ViteFeatureContext {
|
|
10
|
+
viteEnv: Record<string, any>
|
|
11
|
+
mode: string
|
|
12
|
+
appCode: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 获取 Element Plus Vite 配置
|
|
17
|
+
* @param ctx - feature 配置上下文
|
|
18
|
+
* @param ctx.appCode - 应用代码,用于 SCSS 命名空间
|
|
19
|
+
* @returns Vite UserConfig
|
|
20
|
+
*/
|
|
21
|
+
export default ({ appCode }: ViteFeatureContext) => ({
|
|
22
|
+
css: {
|
|
23
|
+
preprocessorOptions: {
|
|
24
|
+
scss: {
|
|
25
|
+
additionalData: (source: string, filename: string) => {
|
|
26
|
+
if (filename.includes('assets/styles/element/index.scss')) {
|
|
27
|
+
return `$namespace: ${appCode || 'el'};
|
|
28
|
+
${source}`
|
|
29
|
+
}
|
|
30
|
+
return source
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* I18n 国际化 feature 设置
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { App } from 'vue'
|
|
6
|
+
import type { Router } from 'vue-router'
|
|
7
|
+
import i18n from '@/locales'
|
|
8
|
+
|
|
9
|
+
/** 执行顺序 */
|
|
10
|
+
export const order = 20
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 设置 i18n
|
|
14
|
+
* @param app - Vue 应用实例
|
|
15
|
+
* @param _router - Vue Router 实例(未使用)
|
|
16
|
+
*/
|
|
17
|
+
export function setup(app: App, _router: Router): void {
|
|
18
|
+
app.use(i18n)
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 布局组件导出
|
|
3
|
+
* 注意:具体的布局组件在对应的 UI 库 feature 中
|
|
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
|
|
@@ -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,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 布局组件导出
|
|
3
|
+
* 注意:具体的布局组件在对应的 UI 库 feature 中
|
|
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
|
|
@@ -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,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pinia 状态管理 feature 设置
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { App } from 'vue'
|
|
6
|
+
import type { Router } from 'vue-router'
|
|
7
|
+
import { store } from '@/stores'
|
|
8
|
+
|
|
9
|
+
/** 执行顺序 - pinia 应该尽早加载 */
|
|
10
|
+
export const order = 10
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 设置 Pinia store
|
|
14
|
+
* @param app - Vue 应用实例
|
|
15
|
+
* @param _router - Vue Router 实例(未使用)
|
|
16
|
+
*/
|
|
17
|
+
export function setup(app: App, _router: Router): void {
|
|
18
|
+
app.use(store)
|
|
19
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@sentry/vue": "^9.27.0",
|
|
4
3
|
"@sentry/vite-plugin": "^3.5.0",
|
|
4
|
+
"@sentry/vue": "^9.27.0",
|
|
5
5
|
"pinia": "^2.2.7",
|
|
6
|
-
"pinia-plugin-persistedstate": "^3.2.1"
|
|
6
|
+
"pinia-plugin-persistedstate": "^3.2.1",
|
|
7
|
+
"vue": "^3.5.13",
|
|
8
|
+
"vue-router": "^4.4.5"
|
|
7
9
|
}
|
|
8
10
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sentry 错误监控 feature 设置
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { App } from 'vue'
|
|
6
|
+
import type { Router } from 'vue-router'
|
|
7
|
+
import { initSentry } from '@/utils/sentry'
|
|
8
|
+
|
|
9
|
+
/** 执行顺序 - sentry 应该在 router 之后初始化 */
|
|
10
|
+
export const order = 30
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 设置 Sentry
|
|
14
|
+
* @param app - Vue 应用实例
|
|
15
|
+
* @param router - Vue Router 实例
|
|
16
|
+
*/
|
|
17
|
+
export function setup(app: App, router: Router): void {
|
|
18
|
+
initSentry(app, router, {
|
|
19
|
+
dsn: import.meta.env.VITE_SENTRY_DSN,
|
|
20
|
+
environment: import.meta.env.MODE,
|
|
21
|
+
})
|
|
22
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sentry Vite 插件配置
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import process from 'node:process'
|
|
6
|
+
import { sentryVitePlugin } from '@sentry/vite-plugin'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Vite feature 配置上下文
|
|
10
|
+
*/
|
|
11
|
+
interface ViteFeatureContext {
|
|
12
|
+
viteEnv: Record<string, any>
|
|
13
|
+
mode: string
|
|
14
|
+
appCode: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 获取 Sentry Vite 配置
|
|
19
|
+
* @param ctx - feature 配置上下文
|
|
20
|
+
* @param ctx.viteEnv - Vite 环境变量
|
|
21
|
+
* @param ctx.mode - 构建模式
|
|
22
|
+
* @returns Vite UserConfig
|
|
23
|
+
*/
|
|
24
|
+
export default ({ viteEnv, mode }: ViteFeatureContext) => ({
|
|
25
|
+
plugins: [
|
|
26
|
+
viteEnv.VITE_SENTRY && mode === 'production' && sentryVitePlugin({
|
|
27
|
+
authToken: process.env.SENTRY_AUTH_TOKEN,
|
|
28
|
+
org: 'f1f562b9b82f',
|
|
29
|
+
project: 'javascript-vue',
|
|
30
|
+
sourcemaps: {
|
|
31
|
+
assets: './dist/**',
|
|
32
|
+
ignore: ['node_modules'],
|
|
33
|
+
},
|
|
34
|
+
release: {
|
|
35
|
+
name: viteEnv.VITE_APP_VERSION || 'unknown',
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
].filter(Boolean),
|
|
39
|
+
})
|
|
@@ -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/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
|