@moluoxixi/create-app 2.0.407 → 2.0.410
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/test.js +168 -87
- package/dist/types/features.d.ts +7 -9
- package/dist/types/features.js +6 -25
- package/dist/types/index.d.ts +20 -13
- package/dist/utils/featureMapping.d.ts +5 -26
- package/dist/utils/featureMapping.js +24 -68
- package/dist/utils/generateFrameworkProject.d.ts +2 -0
- package/dist/utils/generateFrameworkProject.js +136 -21
- package/dist/utils/prompts.js +37 -7
- package/dist/utils/renderFeatures.d.ts +38 -1
- package/dist/utils/renderFeatures.js +121 -37
- package/dist/utils/routeModeMapping.d.ts +14 -0
- package/dist/utils/routeModeMapping.js +15 -0
- package/package.json +2 -3
- package/templates/common/base/package.json +1 -1
- package/templates/common/base/vite.config.ts.ejs +1 -1
- package/templates/react/base/package.json +1 -3
- package/templates/react/base/src/main.tsx.ejs +16 -43
- package/templates/react/features/pageRoutes/package.json +1 -0
- package/templates/react/micro-frontends/qiankun/base/package.json +6 -0
- package/templates/react/micro-frontends/qiankun/base/src/main.tsx.ejs +83 -0
- package/templates/react/micro-frontends/qiankun/base/vite.config.ts.ejs +93 -0
- package/templates/vue/base/package.json +1 -5
- package/templates/vue/base/src/main.ts.ejs +18 -41
- package/templates/vue/features/element-plus/src/layouts/element.vue +1 -4
- package/templates/vue/features/manualRoutes/package.json +0 -1
- package/templates/vue/features/manualRoutes/src/router/index.ts +11 -12
- package/templates/vue/features/manualRoutes/src/router/routes.ts +14 -23
- package/templates/vue/features/pageRoutes/package.json +0 -1
- package/templates/vue/features/pageRoutes/src/router/index.ts +11 -12
- package/templates/vue/features/pinia/node_modules/.bin/tsc +17 -0
- package/templates/vue/features/pinia/node_modules/.bin/tsc.CMD +12 -0
- package/templates/vue/features/pinia/node_modules/.bin/tsc.ps1 +41 -0
- package/templates/vue/features/pinia/node_modules/.bin/tsserver +17 -0
- package/templates/vue/features/pinia/node_modules/.bin/tsserver.CMD +12 -0
- package/templates/vue/features/pinia/node_modules/.bin/tsserver.ps1 +41 -0
- package/templates/vue/features/pinia/package.json +6 -0
- package/templates/vue/micro-frontends/qiankun/base/package.json +6 -0
- package/templates/vue/micro-frontends/qiankun/base/src/main.ts.ejs +87 -0
- package/templates/vue/micro-frontends/qiankun/base/vite.config.ts.ejs +93 -0
- package/templates/vue/micro-frontends/qiankun/features/element-plus/src/layouts/element.vue +120 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/jiti +17 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/jiti.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/jiti.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/sass +17 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/sass.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/sass.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/terser +17 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/terser.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/terser.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/tsc +17 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/tsc.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/tsc.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/tsserver +17 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/tsserver.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/tsserver.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/tsx +17 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/tsx.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/tsx.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/vite +17 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/vite.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/vite.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/yaml +17 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/yaml.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/node_modules/.bin/yaml.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/package.json +5 -0
- package/templates/vue/micro-frontends/qiankun/features/manualRoutes/src/router/index.ts +56 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/jiti +17 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/jiti.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/jiti.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/sass +17 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/sass.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/sass.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/terser +17 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/terser.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/terser.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/tsc +17 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/tsc.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/tsc.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/tsserver +17 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/tsserver.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/tsserver.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/tsx +17 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/tsx.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/tsx.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/vite +17 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/vite.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/vite.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/yaml +17 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/yaml.CMD +12 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/node_modules/.bin/yaml.ps1 +41 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/package.json +5 -0
- package/templates/vue/micro-frontends/qiankun/features/pageRoutes/src/router/index.ts +57 -0
- package/templates/react/base/src/qiankun/index.ts +0 -83
- package/templates/react/base/src/stores/user.ts +0 -55
- package/templates/vue/base/src/router/layout.vue +0 -15
- package/templates/vue/features/manualRoutes/src/stores/index.ts +0 -6
- package/templates/vue/features/manualRoutes/src/stores/modules/system.ts +0 -51
- package/templates/vue/features/manualRoutes/src/stores/modules/user.ts +0 -41
- package/templates/vue/features/pageRoutes/src/stores/index.ts +0 -6
- package/templates/vue/features/pageRoutes/src/stores/modules/system.ts +0 -51
- package/templates/vue/features/pageRoutes/src/stores/modules/user.ts +0 -41
- /package/templates/react/features/{router → manualRoutes}/package.json +0 -0
- /package/templates/react/{base → features/zustand}/src/stores/index.ts +0 -0
- /package/templates/vue/{base → features/pinia}/src/stores/index.ts +0 -0
- /package/templates/vue/{base → features/pinia}/src/stores/modules/system.ts +0 -0
- /package/templates/vue/{base → features/pinia}/src/stores/modules/user.ts +0 -0
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 应用入口文件
|
|
2
|
+
* 应用入口文件 - 标准模式
|
|
3
3
|
* 初始化 React 应用并挂载到 DOM
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
<% if (qiankun) { -%>
|
|
7
|
-
import { qiankunWindow, renderWithQiankun } from 'vite-plugin-qiankun/dist/helper'
|
|
8
|
-
<% } -%>
|
|
9
6
|
import React from 'react'
|
|
10
7
|
import ReactDOM from 'react-dom/client'
|
|
8
|
+
<% if (hasRouter) { -%>
|
|
11
9
|
import { RouterProvider } from 'react-router-dom'
|
|
10
|
+
import { createRouter } from '@/router'
|
|
11
|
+
<% } else { -%>
|
|
12
|
+
import App from './App'
|
|
13
|
+
<% } -%>
|
|
12
14
|
<% if (i18n) { -%>
|
|
13
15
|
import '@/locales'
|
|
14
16
|
<% } -%>
|
|
15
17
|
<% if (sentry) { -%>
|
|
16
18
|
import { initSentry } from '@/utils/sentry'
|
|
17
19
|
<% } -%>
|
|
18
|
-
import { createRouter } from '@/router'
|
|
19
20
|
|
|
20
21
|
// 导入样式文件
|
|
21
22
|
<% if (uiLibrary === 'ant-design') { -%>
|
|
@@ -32,52 +33,24 @@ initSentry({
|
|
|
32
33
|
})
|
|
33
34
|
|
|
34
35
|
<% } -%>
|
|
35
|
-
let root: ReturnType<typeof ReactDOM.createRoot> | null = null
|
|
36
|
-
|
|
37
36
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @param props 渲染属性
|
|
37
|
+
* 初始化并渲染应用
|
|
40
38
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<% if (qiankun) { -%>
|
|
44
|
-
const basename = qiankunWindow.__POWERED_BY_QIANKUN__
|
|
45
|
-
? (qiankunWindow as { __INJECTED_PUBLIC_PATH_BY_QIANKUN__?: string }).__INJECTED_PUBLIC_PATH_BY_QIANKUN__?.split('/')[1]
|
|
46
|
-
: undefined
|
|
47
|
-
const router = createRouter({ basename })
|
|
48
|
-
<% } else { -%>
|
|
39
|
+
function initApp(): void {
|
|
40
|
+
<% if (hasRouter) { -%>
|
|
49
41
|
const router = createRouter()
|
|
50
42
|
<% } -%>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
? container.querySelector('#root') || container
|
|
54
|
-
: document.getElementById('root')!
|
|
55
|
-
|
|
56
|
-
root = ReactDOM.createRoot(containerElement)
|
|
43
|
+
const root = ReactDOM.createRoot(document.getElementById('root')!)
|
|
44
|
+
|
|
57
45
|
root.render(
|
|
58
46
|
<React.StrictMode>
|
|
47
|
+
<% if (hasRouter) { -%>
|
|
59
48
|
<RouterProvider router={router} />
|
|
49
|
+
<% } else { -%>
|
|
50
|
+
<App />
|
|
51
|
+
<% } -%>
|
|
60
52
|
</React.StrictMode>,
|
|
61
53
|
)
|
|
62
54
|
}
|
|
63
55
|
|
|
64
|
-
|
|
65
|
-
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
|
|
66
|
-
render({})
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
renderWithQiankun({
|
|
70
|
-
async mount(props: Record<string, unknown>) {
|
|
71
|
-
await render(props)
|
|
72
|
-
},
|
|
73
|
-
bootstrap() {},
|
|
74
|
-
unmount() {
|
|
75
|
-
root?.unmount()
|
|
76
|
-
root = null
|
|
77
|
-
},
|
|
78
|
-
update() {},
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
<% } else { -%>
|
|
82
|
-
render({})
|
|
83
|
-
<% } -%>
|
|
56
|
+
initApp()
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 应用入口文件 - Qiankun 微前端模式
|
|
3
|
+
* 初始化 React 应用并挂载到 DOM(支持 qiankun 生命周期)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { qiankunWindow, renderWithQiankun } from 'vite-plugin-qiankun/dist/helper'
|
|
7
|
+
import React from 'react'
|
|
8
|
+
import ReactDOM from 'react-dom/client'
|
|
9
|
+
import { RouterProvider } from 'react-router-dom'
|
|
10
|
+
<% if (i18n) { -%>
|
|
11
|
+
import '@/locales'
|
|
12
|
+
<% } -%>
|
|
13
|
+
<% if (sentry) { -%>
|
|
14
|
+
import { initSentry } from '@/utils/sentry'
|
|
15
|
+
<% } -%>
|
|
16
|
+
import { createRouter } from '@/router'
|
|
17
|
+
|
|
18
|
+
// 导入样式文件
|
|
19
|
+
<% if (uiLibrary === 'ant-design') { -%>
|
|
20
|
+
import 'antd/dist/reset.css'
|
|
21
|
+
<% } -%>
|
|
22
|
+
import '@/assets/styles/main.scss'
|
|
23
|
+
import '@/assets/fonts/index.css'
|
|
24
|
+
|
|
25
|
+
<% if (sentry) { -%>
|
|
26
|
+
// 初始化 Sentry
|
|
27
|
+
initSentry({
|
|
28
|
+
dsn: import.meta.env.VITE_SENTRY_DSN,
|
|
29
|
+
environment: import.meta.env.MODE,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
<% } -%>
|
|
33
|
+
let root: ReturnType<typeof ReactDOM.createRoot> | null = null
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 渲染应用
|
|
37
|
+
* @param props 渲染属性
|
|
38
|
+
*/
|
|
39
|
+
async function render(props: Record<string, unknown> = {}): Promise<void> {
|
|
40
|
+
const { container } = props as { container?: Element }
|
|
41
|
+
|
|
42
|
+
const basename = qiankunWindow.__POWERED_BY_QIANKUN__
|
|
43
|
+
? (qiankunWindow as { __INJECTED_PUBLIC_PATH_BY_QIANKUN__?: string }).__INJECTED_PUBLIC_PATH_BY_QIANKUN__?.split('/')[1]
|
|
44
|
+
: undefined
|
|
45
|
+
const router = createRouter({ basename })
|
|
46
|
+
|
|
47
|
+
const containerElement = container
|
|
48
|
+
? container.querySelector('#root') || container
|
|
49
|
+
: document.getElementById('root')!
|
|
50
|
+
|
|
51
|
+
root = ReactDOM.createRoot(containerElement)
|
|
52
|
+
root.render(
|
|
53
|
+
<React.StrictMode>
|
|
54
|
+
<RouterProvider router={router} />
|
|
55
|
+
</React.StrictMode>,
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Qiankun 生命周期
|
|
60
|
+
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
|
|
61
|
+
// 独立运行模式
|
|
62
|
+
render({})
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// 微前端运行模式
|
|
66
|
+
renderWithQiankun({
|
|
67
|
+
async mount(props: Record<string, unknown>) {
|
|
68
|
+
await render(props)
|
|
69
|
+
},
|
|
70
|
+
bootstrap() {
|
|
71
|
+
console.log('[Qiankun] React app bootstrapped')
|
|
72
|
+
},
|
|
73
|
+
unmount() {
|
|
74
|
+
root?.unmount()
|
|
75
|
+
root = null
|
|
76
|
+
console.log('[Qiankun] React app unmounted')
|
|
77
|
+
},
|
|
78
|
+
update() {
|
|
79
|
+
console.log('[Qiankun] React app updated')
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import process from 'node:process'
|
|
3
|
+
import cssModuleGlobalRootPlugin from '@moluoxixi/css-module-global-root-plugin'
|
|
4
|
+
import { ViteConfig, wrapperEnv } from '@moluoxixi/vite-config'
|
|
5
|
+
import { loadEnv } from 'vite'
|
|
6
|
+
<% if (sentry) { -%>
|
|
7
|
+
import { sentryVitePlugin } from '@sentry/vite-plugin'
|
|
8
|
+
<% } -%>
|
|
9
|
+
import qiankun from 'vite-plugin-qiankun'
|
|
10
|
+
|
|
11
|
+
export default ViteConfig(
|
|
12
|
+
({ mode }) => {
|
|
13
|
+
const env = loadEnv(mode!, process.cwd())
|
|
14
|
+
const viteEnv = wrapperEnv(env)
|
|
15
|
+
const rootPath = path.resolve()
|
|
16
|
+
const appCode = viteEnv.VITE_APP_CODE
|
|
17
|
+
const appTitle = viteEnv.VITE_APP_TITLE
|
|
18
|
+
const port = viteEnv.VITE_APP_PORT
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
rootPath,
|
|
22
|
+
appTitle,
|
|
23
|
+
appCode,
|
|
24
|
+
port,
|
|
25
|
+
<% if (framework === 'vue') { -%>
|
|
26
|
+
vue: true,
|
|
27
|
+
autoComponent: true,
|
|
28
|
+
<% } else if (framework === 'react') { -%>
|
|
29
|
+
react: true,
|
|
30
|
+
<% } -%>
|
|
31
|
+
<% if (routeMode === 'pageRoutes') { -%>
|
|
32
|
+
pageRoutes: true,
|
|
33
|
+
<% } -%>
|
|
34
|
+
viteConfig: {
|
|
35
|
+
plugins: [
|
|
36
|
+
qiankun(appCode, {
|
|
37
|
+
useDevMode: true,
|
|
38
|
+
}),
|
|
39
|
+
<% if (sentry) { -%>
|
|
40
|
+
viteEnv.VITE_SENTRY && mode === 'production' && sentryVitePlugin({
|
|
41
|
+
authToken: process.env.SENTRY_AUTH_TOKEN,
|
|
42
|
+
org: 'f1f562b9b82f',
|
|
43
|
+
project: 'javascript-<%= framework %>',
|
|
44
|
+
sourcemaps: {
|
|
45
|
+
assets: './dist/**',
|
|
46
|
+
ignore: ['node_modules'],
|
|
47
|
+
},
|
|
48
|
+
release: {
|
|
49
|
+
name: viteEnv.VITE_APP_VERSION || 'unknown',
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
<% } -%>
|
|
53
|
+
],
|
|
54
|
+
server: {
|
|
55
|
+
proxy: {
|
|
56
|
+
'/api': {
|
|
57
|
+
changeOrigin: true,
|
|
58
|
+
target: 'http://localhost:3000',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
headers: {
|
|
62
|
+
'Access-Control-Allow-Origin': '*',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
css: {
|
|
66
|
+
preprocessorOptions: {
|
|
67
|
+
scss: {
|
|
68
|
+
silenceDeprecations: ['legacy-js-api'],
|
|
69
|
+
api: 'modern-compiler',
|
|
70
|
+
<% if (uiLibrary === 'element-plus') { -%>
|
|
71
|
+
additionalData: (source: string, filename: string) => {
|
|
72
|
+
if (filename.includes('assets/styles/element/index.scss')) {
|
|
73
|
+
return `$namespace : ${appCode || 'el'};
|
|
74
|
+
${source}`
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return source
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
<% } -%>
|
|
81
|
+
},
|
|
82
|
+
postcss: {
|
|
83
|
+
plugins: [
|
|
84
|
+
cssModuleGlobalRootPlugin() as any,
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
)
|
|
93
|
+
|
|
@@ -4,11 +4,7 @@
|
|
|
4
4
|
"type-check": "vue-tsc --noEmit"
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"vue": "^3.5.13"
|
|
8
|
-
"vite-plugin-qiankun": "^1.0.15",
|
|
9
|
-
"pinia": "^2.2.7",
|
|
10
|
-
"pinia-plugin-persistedstate": "^3.2.1",
|
|
11
|
-
"vue-router": "^4.4.5"
|
|
7
|
+
"vue": "^3.5.13"
|
|
12
8
|
},
|
|
13
9
|
"devDependencies": {
|
|
14
10
|
"@moluoxixi/css-module-global-root-plugin": "latest",
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 应用入口文件
|
|
2
|
+
* 应用入口文件 - 标准模式
|
|
3
3
|
* 初始化 Vue 应用并挂载到 DOM
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
<% if (qiankun) { -%>
|
|
7
|
-
import { qiankunWindow, renderWithQiankun } from 'vite-plugin-qiankun/dist/helper'
|
|
8
|
-
<% } -%>
|
|
9
6
|
import { createApp } from 'vue'
|
|
10
7
|
import directives from '@/directives'
|
|
11
8
|
<% if (i18n) { -%>
|
|
@@ -14,71 +11,51 @@ import i18n from '@/locales'
|
|
|
14
11
|
<% if (sentry) { -%>
|
|
15
12
|
import { initSentry } from '@/utils/sentry'
|
|
16
13
|
<% } -%>
|
|
14
|
+
<% if (pinia) { -%>
|
|
17
15
|
import { store } from '@/stores'
|
|
16
|
+
<% } -%>
|
|
18
17
|
import App from './App.vue'
|
|
18
|
+
<% if (hasRouter) { -%>
|
|
19
19
|
import getRouter from './router'
|
|
20
|
+
<% } -%>
|
|
20
21
|
|
|
21
22
|
// 导入样式文件
|
|
22
23
|
<% if (uiLibrary === 'element-plus') { -%>
|
|
23
24
|
import '@/assets/styles/element/index.scss'
|
|
24
|
-
import '@/assets/styles/element/fixQiankun.scss'
|
|
25
25
|
<% } -%>
|
|
26
26
|
import '@/assets/styles/main.scss'
|
|
27
27
|
import '@/assets/fonts/index.css'
|
|
28
28
|
|
|
29
|
-
let app: ReturnType<typeof createApp> | null = null
|
|
30
|
-
|
|
31
29
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @param props 渲染属性
|
|
30
|
+
* 初始化并渲染应用
|
|
34
31
|
*/
|
|
35
|
-
async function
|
|
36
|
-
const
|
|
37
|
-
app = createApp(App)
|
|
32
|
+
async function initApp(): Promise<void> {
|
|
33
|
+
const app = createApp(App)
|
|
38
34
|
|
|
39
35
|
directives(app)
|
|
40
|
-
|
|
36
|
+
<% if (hasRouter) { -%>
|
|
37
|
+
const router = getRouter()
|
|
41
38
|
|
|
39
|
+
<% } -%>
|
|
42
40
|
<% if (sentry) { -%>
|
|
43
|
-
initSentry(app
|
|
41
|
+
initSentry(app<% if (hasRouter) { %>, router<% } %>, {
|
|
44
42
|
dsn: import.meta.env.VITE_SENTRY_DSN,
|
|
45
43
|
environment: import.meta.env.MODE,
|
|
46
44
|
})
|
|
47
45
|
|
|
48
46
|
<% } -%>
|
|
47
|
+
<% if (pinia) { -%>
|
|
49
48
|
app.use(store)
|
|
49
|
+
<% } -%>
|
|
50
50
|
<% if (i18n) { -%>
|
|
51
51
|
app.use(i18n)
|
|
52
52
|
<% } -%>
|
|
53
|
+
<% if (hasRouter) { -%>
|
|
53
54
|
app.use(router)
|
|
55
|
+
<% } -%>
|
|
54
56
|
app.config.warnHandler = () => null
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
const root = container.querySelector('#app')
|
|
58
|
-
app.mount(root)
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
app.mount('#app')
|
|
62
|
-
}
|
|
58
|
+
app.mount('#app')
|
|
63
59
|
}
|
|
64
60
|
|
|
65
|
-
|
|
66
|
-
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
|
|
67
|
-
render({})
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
renderWithQiankun({
|
|
71
|
-
async mount(props: Record<string, unknown>) {
|
|
72
|
-
await render(props)
|
|
73
|
-
},
|
|
74
|
-
bootstrap() {},
|
|
75
|
-
unmount() {
|
|
76
|
-
app?.unmount()
|
|
77
|
-
app = null
|
|
78
|
-
},
|
|
79
|
-
update() {},
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
<% } else { -%>
|
|
83
|
-
render({})
|
|
84
|
-
<% } -%>
|
|
61
|
+
initApp()
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<ElConfigProvider :namespace="systemCode" :empty-values="[undefined]">
|
|
3
3
|
<div
|
|
4
|
-
class="h-full"
|
|
5
|
-
:class="{ 'h-screen!': !qiankunWindow.__POWERED_BY_QIANKUN__ }"
|
|
4
|
+
class="h-full h-screen!"
|
|
6
5
|
:style="`--el-color-primary: ${themeColor || '#3A77FF'};`"
|
|
7
6
|
>
|
|
8
7
|
<ElContainer class="w-full h-full">
|
|
9
8
|
<ElHeader
|
|
10
|
-
v-if="!qiankunWindow.__POWERED_BY_QIANKUN__"
|
|
11
9
|
class="headerbox"
|
|
12
10
|
style="padding: 0"
|
|
13
11
|
height="60"
|
|
@@ -39,7 +37,6 @@
|
|
|
39
37
|
|
|
40
38
|
<script lang="ts" setup>
|
|
41
39
|
import { ElConfigProvider, ElContainer, ElHeader, ElMain, ElMenu } from 'element-plus'
|
|
42
|
-
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
|
|
43
40
|
import { computed, reactive } from 'vue'
|
|
44
41
|
import { RouterView, useRouter } from 'vue-router'
|
|
45
42
|
import SubMenu from '@/components/SubMenu'
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { cloneDeep } from 'lodash-es'
|
|
2
2
|
import { assign, isEmpty } from 'radash'
|
|
3
3
|
import { routes } from './routes'
|
|
4
|
-
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
|
|
5
4
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
6
5
|
|
|
7
6
|
// 手动配置的路由
|
|
@@ -19,26 +18,26 @@ const Routes = [
|
|
|
19
18
|
},
|
|
20
19
|
]
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
base = import.meta.env.VITE_APP_CODE
|
|
31
|
-
}
|
|
21
|
+
/**
|
|
22
|
+
* 创建路由实例
|
|
23
|
+
* @returns 路由实例
|
|
24
|
+
*/
|
|
25
|
+
function getRouter() {
|
|
26
|
+
const base = import.meta.env.VITE_APP_CODE
|
|
27
|
+
const routesClone = cloneDeep(Routes)
|
|
28
|
+
|
|
32
29
|
const router = createRouter({
|
|
33
30
|
history: createWebHistory(base),
|
|
34
|
-
routes,
|
|
31
|
+
routes: routesClone,
|
|
35
32
|
})
|
|
33
|
+
|
|
36
34
|
router.beforeEach((_, from, next) => {
|
|
37
35
|
if (isEmpty(history.state.current)) {
|
|
38
36
|
assign(history.state, { current: from.fullPath })
|
|
39
37
|
}
|
|
40
38
|
next()
|
|
41
39
|
})
|
|
40
|
+
|
|
42
41
|
return router
|
|
43
42
|
}
|
|
44
43
|
|
|
@@ -3,33 +3,24 @@
|
|
|
3
3
|
* 手动配置路由表
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import Layout from './layout.vue'
|
|
7
|
-
|
|
8
6
|
/**
|
|
9
7
|
* 路由配置数组
|
|
10
8
|
*/
|
|
11
9
|
export const routes = [
|
|
12
10
|
{
|
|
13
|
-
path: '/',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
name: 'About',
|
|
28
|
-
component: () => import('@/pages/about/index.vue'),
|
|
29
|
-
meta: {
|
|
30
|
-
title: '关于',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
],
|
|
11
|
+
path: '/home',
|
|
12
|
+
name: 'Home',
|
|
13
|
+
component: () => import('@/pages/home/index.vue'),
|
|
14
|
+
meta: {
|
|
15
|
+
title: '首页',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
path: '/about',
|
|
20
|
+
name: 'About',
|
|
21
|
+
component: () => import('@/pages/about/index.vue'),
|
|
22
|
+
meta: {
|
|
23
|
+
title: '关于',
|
|
24
|
+
},
|
|
34
25
|
},
|
|
35
26
|
]
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { cloneDeep } from 'lodash-es'
|
|
2
2
|
import { assign, isEmpty } from 'radash'
|
|
3
3
|
import routes from '~pages'
|
|
4
|
-
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
|
|
5
4
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
6
5
|
|
|
7
6
|
// 自动生成的路由
|
|
@@ -20,26 +19,26 @@ const Routes = [
|
|
|
20
19
|
},
|
|
21
20
|
]
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
base = import.meta.env.VITE_APP_CODE
|
|
32
|
-
}
|
|
22
|
+
/**
|
|
23
|
+
* 创建路由实例
|
|
24
|
+
* @returns 路由实例
|
|
25
|
+
*/
|
|
26
|
+
function getRouter() {
|
|
27
|
+
const base = import.meta.env.VITE_APP_CODE
|
|
28
|
+
const routesClone = cloneDeep(Routes)
|
|
29
|
+
|
|
33
30
|
const router = createRouter({
|
|
34
31
|
history: createWebHistory(base),
|
|
35
|
-
routes,
|
|
32
|
+
routes: routesClone,
|
|
36
33
|
})
|
|
34
|
+
|
|
37
35
|
router.beforeEach((_, from, next) => {
|
|
38
36
|
if (isEmpty(history.state.current)) {
|
|
39
37
|
assign(history.state, { current: from.fullPath })
|
|
40
38
|
}
|
|
41
39
|
next()
|
|
42
40
|
})
|
|
41
|
+
|
|
43
42
|
return router
|
|
44
43
|
}
|
|
45
44
|
|
|
@@ -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/typescript@5.8.3/node_modules/typescript/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsc" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsc" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@SETLOCAL
|
|
2
|
+
@IF NOT DEFINED NODE_PATH (
|
|
3
|
+
@SET "NODE_PATH=E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules"
|
|
4
|
+
) ELSE (
|
|
5
|
+
@SET "NODE_PATH=E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules;%NODE_PATH%"
|
|
6
|
+
)
|
|
7
|
+
@IF EXIST "%~dp0\node.exe" (
|
|
8
|
+
"%~dp0\node.exe" "%~dp0\..\..\..\..\..\..\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\tsc" %*
|
|
9
|
+
) ELSE (
|
|
10
|
+
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
11
|
+
node "%~dp0\..\..\..\..\..\..\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\tsc" %*
|
|
12
|
+
)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
3
|
+
|
|
4
|
+
$exe=""
|
|
5
|
+
$pathsep=":"
|
|
6
|
+
$env_node_path=$env:NODE_PATH
|
|
7
|
+
$new_node_path="E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules"
|
|
8
|
+
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
9
|
+
# Fix case when both the Windows and Linux builds of Node
|
|
10
|
+
# are installed in the same directory
|
|
11
|
+
$exe=".exe"
|
|
12
|
+
$pathsep=";"
|
|
13
|
+
} else {
|
|
14
|
+
$new_node_path="/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules"
|
|
15
|
+
}
|
|
16
|
+
if ([string]::IsNullOrEmpty($env_node_path)) {
|
|
17
|
+
$env:NODE_PATH=$new_node_path
|
|
18
|
+
} else {
|
|
19
|
+
$env:NODE_PATH="$new_node_path$pathsep$env_node_path"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
$ret=0
|
|
23
|
+
if (Test-Path "$basedir/node$exe") {
|
|
24
|
+
# Support pipeline input
|
|
25
|
+
if ($MyInvocation.ExpectingInput) {
|
|
26
|
+
$input | & "$basedir/node$exe" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsc" $args
|
|
27
|
+
} else {
|
|
28
|
+
& "$basedir/node$exe" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsc" $args
|
|
29
|
+
}
|
|
30
|
+
$ret=$LASTEXITCODE
|
|
31
|
+
} else {
|
|
32
|
+
# Support pipeline input
|
|
33
|
+
if ($MyInvocation.ExpectingInput) {
|
|
34
|
+
$input | & "node$exe" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsc" $args
|
|
35
|
+
} else {
|
|
36
|
+
& "node$exe" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsc" $args
|
|
37
|
+
}
|
|
38
|
+
$ret=$LASTEXITCODE
|
|
39
|
+
}
|
|
40
|
+
$env:NODE_PATH=$env_node_path
|
|
41
|
+
exit $ret
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsserver" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsserver" "$@"
|
|
17
|
+
fi
|