@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.
Files changed (215) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +129 -0
  3. package/dist/commands/create.d.ts +10 -0
  4. package/dist/commands/create.d.ts.map +1 -0
  5. package/dist/commands/create.js +89 -0
  6. package/dist/commands/create.js.map +1 -0
  7. package/dist/commands/index.d.ts +5 -0
  8. package/dist/commands/index.d.ts.map +1 -0
  9. package/dist/commands/index.js +5 -0
  10. package/dist/commands/index.js.map +1 -0
  11. package/dist/generators/index.d.ts +7 -0
  12. package/dist/generators/index.d.ts.map +1 -0
  13. package/dist/generators/index.js +7 -0
  14. package/dist/generators/index.js.map +1 -0
  15. package/dist/generators/project.d.ts +11 -0
  16. package/dist/generators/project.d.ts.map +1 -0
  17. package/dist/generators/project.js +26 -0
  18. package/dist/generators/project.js.map +1 -0
  19. package/dist/generators/react.d.ts +10 -0
  20. package/dist/generators/react.d.ts.map +1 -0
  21. package/dist/generators/react.js +39 -0
  22. package/dist/generators/react.js.map +1 -0
  23. package/dist/generators/vue.d.ts +10 -0
  24. package/dist/generators/vue.d.ts.map +1 -0
  25. package/dist/generators/vue.js +40 -0
  26. package/dist/generators/vue.js.map +1 -0
  27. package/dist/index.d.ts +7 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +26 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/test.d.ts +6 -0
  32. package/dist/test.d.ts.map +1 -0
  33. package/dist/test.js +364 -0
  34. package/dist/test.js.map +1 -0
  35. package/dist/types/ejs.d.ts +11 -0
  36. package/dist/types/ejs.d.ts.map +1 -0
  37. package/dist/types/ejs.js +5 -0
  38. package/dist/types/ejs.js.map +1 -0
  39. package/dist/types/features.d.ts +26 -0
  40. package/dist/types/features.d.ts.map +1 -0
  41. package/dist/types/features.js +41 -0
  42. package/dist/types/features.js.map +1 -0
  43. package/dist/types/index.d.ts +59 -0
  44. package/dist/types/index.d.ts.map +1 -0
  45. package/dist/types/index.js +8 -0
  46. package/dist/types/index.js.map +1 -0
  47. package/dist/types/viteConfig.d.ts +17 -0
  48. package/dist/types/viteConfig.d.ts.map +1 -0
  49. package/dist/types/viteConfig.js +6 -0
  50. package/dist/types/viteConfig.js.map +1 -0
  51. package/dist/utils/deepMerge.d.ts +8 -0
  52. package/dist/utils/deepMerge.d.ts.map +1 -0
  53. package/dist/utils/deepMerge.js +33 -0
  54. package/dist/utils/deepMerge.js.map +1 -0
  55. package/dist/utils/ejs.d.ts +19 -0
  56. package/dist/utils/ejs.d.ts.map +1 -0
  57. package/dist/utils/ejs.js +30 -0
  58. package/dist/utils/ejs.js.map +1 -0
  59. package/dist/utils/file.d.ts +70 -0
  60. package/dist/utils/file.d.ts.map +1 -0
  61. package/dist/utils/file.js +119 -0
  62. package/dist/utils/file.js.map +1 -0
  63. package/dist/utils/index.d.ts +12 -0
  64. package/dist/utils/index.d.ts.map +1 -0
  65. package/dist/utils/index.js +12 -0
  66. package/dist/utils/index.js.map +1 -0
  67. package/dist/utils/install.d.ts +17 -0
  68. package/dist/utils/install.d.ts.map +1 -0
  69. package/dist/utils/install.js +37 -0
  70. package/dist/utils/install.js.map +1 -0
  71. package/dist/utils/prompts.d.ts +16 -0
  72. package/dist/utils/prompts.d.ts.map +1 -0
  73. package/dist/utils/prompts.js +180 -0
  74. package/dist/utils/prompts.js.map +1 -0
  75. package/dist/utils/renderFeatures.d.ts +18 -0
  76. package/dist/utils/renderFeatures.d.ts.map +1 -0
  77. package/dist/utils/renderFeatures.js +72 -0
  78. package/dist/utils/renderFeatures.js.map +1 -0
  79. package/dist/utils/renderTemplate.d.ts +6 -0
  80. package/dist/utils/renderTemplate.d.ts.map +1 -0
  81. package/dist/utils/renderTemplate.js +102 -0
  82. package/dist/utils/renderTemplate.js.map +1 -0
  83. package/dist/utils/sortDependencies.d.ts +6 -0
  84. package/dist/utils/sortDependencies.d.ts.map +1 -0
  85. package/dist/utils/sortDependencies.js +22 -0
  86. package/dist/utils/sortDependencies.js.map +1 -0
  87. package/dist/utils/viteConfigRender.d.ts +19 -0
  88. package/dist/utils/viteConfigRender.d.ts.map +1 -0
  89. package/dist/utils/viteConfigRender.js +180 -0
  90. package/dist/utils/viteConfigRender.js.map +1 -0
  91. package/package.json +93 -0
  92. package/templates/common/base/.env +7 -0
  93. package/templates/common/base/.env.development +5 -0
  94. package/templates/common/base/.env.production +5 -0
  95. package/templates/common/base/package.json +56 -0
  96. package/templates/common/base/pnpm-workspace.yaml +37 -0
  97. package/templates/common/base/scripts/build.mts +31 -0
  98. package/templates/common/base/src/apis/index.ts +8 -0
  99. package/templates/common/base/src/apis/request.ts +43 -0
  100. package/templates/common/base/src/apis/services/example.ts +40 -0
  101. package/templates/common/base/src/apis/services/user.ts +23 -0
  102. package/templates/common/base/src/apis/types/common.ts +28 -0
  103. package/templates/common/base/src/apis/types/example.ts +18 -0
  104. package/templates/common/base/src/apis/types/index.ts +7 -0
  105. package/templates/common/base/src/apis/types/user.ts +24 -0
  106. package/templates/common/base/src/assets/fonts/index.css +7 -0
  107. package/templates/common/base/src/assets/styles/base.scss +72 -0
  108. package/templates/common/base/src/assets/styles/custom.scss +7 -0
  109. package/templates/common/base/src/assets/styles/tailwind.scss +6 -0
  110. package/templates/common/base/src/constants/index.ts +29 -0
  111. package/templates/common/base/src/locales/lang/en.ts +30 -0
  112. package/templates/common/base/src/locales/lang/es.ts +30 -0
  113. package/templates/common/base/src/locales/lang/zh.ts +30 -0
  114. package/templates/common/base/src/utils/index.ts +83 -0
  115. package/templates/common/features/husky/.cz-config.cjs +35 -0
  116. package/templates/common/features/husky/.husky/commit-msg +9 -0
  117. package/templates/common/features/husky/.husky/install.mjs +6 -0
  118. package/templates/common/features/husky/.husky/pre-commit +4 -0
  119. package/templates/common/features/husky/commitlint.config.ts +32 -0
  120. package/templates/common/features/husky/package.json +28 -0
  121. package/templates/common/features/husky/pnpm-workspace.yaml +9 -0
  122. package/templates/react/base/env.d.ts +19 -0
  123. package/templates/react/base/index.html +14 -0
  124. package/templates/react/base/package.json +15 -0
  125. package/templates/react/base/pnpm-workspace.yaml +9 -0
  126. package/templates/react/base/src/App.tsx +18 -0
  127. package/templates/react/base/src/assets/styles/main.scss +8 -0
  128. package/templates/react/base/src/main.tsx.ejs +39 -0
  129. package/templates/react/base/src/pages/about/index.tsx +14 -0
  130. package/templates/react/base/src/pages/home/index.tsx +14 -0
  131. package/templates/react/base/src/router/index.tsx.ejs +28 -0
  132. package/templates/react/base/src/stores/user.ts +39 -0
  133. package/templates/react/base/tsconfig.app.json +17 -0
  134. package/templates/react/base/tsconfig.base.json +23 -0
  135. package/templates/react/base/tsconfig.json +12 -0
  136. package/templates/react/base/tsconfig.node.json +15 -0
  137. package/templates/react/base/vite.config.ts +52 -0
  138. package/templates/react/features/ant-design/package.json +7 -0
  139. package/templates/react/features/ant-design/pnpm-workspace.yaml +5 -0
  140. package/templates/react/features/eslint/eslint.config.ts +12 -0
  141. package/templates/react/features/eslint/package.json +7 -0
  142. package/templates/react/features/eslint/pnpm-workspace.yaml +6 -0
  143. package/templates/react/features/i18n/package.json +7 -0
  144. package/templates/react/features/i18n/pnpm-workspace.yaml +5 -0
  145. package/templates/react/features/i18n/src/locales/index.ts +20 -0
  146. package/templates/react/features/manualRoutes/src/router/routes.tsx +21 -0
  147. package/templates/react/features/pageRoutes/package.json +6 -0
  148. package/templates/react/features/pageRoutes/pnpm-workspace.yaml +4 -0
  149. package/templates/react/features/pageRoutes/vite.config.data.ts +10 -0
  150. package/templates/react/features/router/package.json +5 -0
  151. package/templates/react/features/router/pnpm-workspace.yaml +3 -0
  152. package/templates/react/features/sentry/package.json +7 -0
  153. package/templates/react/features/sentry/pnpm-workspace.yaml +5 -0
  154. package/templates/react/features/sentry/src/utils/sentry.ts +30 -0
  155. package/templates/react/features/sentry/vite.config.data.ts +23 -0
  156. package/templates/react/features/zustand/package.json +5 -0
  157. package/templates/react/features/zustand/pnpm-workspace.yaml +3 -0
  158. package/templates/react/features/zustand/src/stores/user.ts +19 -0
  159. package/templates/react/features/zustand/src/types/stores.ts +15 -0
  160. package/templates/vue/base/env.d.ts +27 -0
  161. package/templates/vue/base/index.html +14 -0
  162. package/templates/vue/base/package.json +13 -0
  163. package/templates/vue/base/pnpm-workspace.yaml +6 -0
  164. package/templates/vue/base/src/App.vue +13 -0
  165. package/templates/vue/base/src/assets/styles/element/index.scss +27 -0
  166. package/templates/vue/base/src/assets/styles/main.scss +9 -0
  167. package/templates/vue/base/src/components/SubMenu/index.ts +9 -0
  168. package/templates/vue/base/src/components/SubMenu/src/_types/index.ts +6 -0
  169. package/templates/vue/base/src/components/SubMenu/src/_types/props.ts +11 -0
  170. package/templates/vue/base/src/components/SubMenu/src/index.vue +24 -0
  171. package/templates/vue/base/src/directives/index.ts +36 -0
  172. package/templates/vue/base/src/layouts/AntDesign.vue +86 -0
  173. package/templates/vue/base/src/layouts/element.vue +81 -0
  174. package/templates/vue/base/src/layouts/index.ts +7 -0
  175. package/templates/vue/base/src/main.ts.ejs +100 -0
  176. package/templates/vue/base/src/pages/about/index.vue +31 -0
  177. package/templates/vue/base/src/pages/home/index.vue +31 -0
  178. package/templates/vue/base/src/router/index.ts.ejs +39 -0
  179. package/templates/vue/base/src/stores/index.ts +16 -0
  180. package/templates/vue/base/src/stores/modules/system.ts +52 -0
  181. package/templates/vue/base/src/stores/modules/user.ts +48 -0
  182. package/templates/vue/base/tsconfig.app.json +17 -0
  183. package/templates/vue/base/tsconfig.base.json +23 -0
  184. package/templates/vue/base/tsconfig.json +12 -0
  185. package/templates/vue/base/tsconfig.node.json +15 -0
  186. package/templates/vue/base/vite.config.ts +53 -0
  187. package/templates/vue/features/ant-design-vue/package.json +7 -0
  188. package/templates/vue/features/ant-design-vue/pnpm-workspace.yaml +5 -0
  189. package/templates/vue/features/element-plus/package.json +7 -0
  190. package/templates/vue/features/element-plus/pnpm-workspace.yaml +5 -0
  191. package/templates/vue/features/element-plus/vite.config.data.ts +15 -0
  192. package/templates/vue/features/eslint/eslint.config.ts +12 -0
  193. package/templates/vue/features/eslint/package.json +7 -0
  194. package/templates/vue/features/eslint/pnpm-workspace.yaml +6 -0
  195. package/templates/vue/features/i18n/package.json +5 -0
  196. package/templates/vue/features/i18n/pnpm-workspace.yaml +3 -0
  197. package/templates/vue/features/i18n/src/locales/index.ts +16 -0
  198. package/templates/vue/features/manualRoutes/src/router/layout.vue +10 -0
  199. package/templates/vue/features/manualRoutes/src/router/routes.ts +27 -0
  200. package/templates/vue/features/pageRoutes/package.json +5 -0
  201. package/templates/vue/features/pageRoutes/pnpm-workspace.yaml +4 -0
  202. package/templates/vue/features/pageRoutes/vite.config.data.ts +9 -0
  203. package/templates/vue/features/pinia/package.json +6 -0
  204. package/templates/vue/features/pinia/pnpm-workspace.yaml +4 -0
  205. package/templates/vue/features/pinia/src/stores/index.ts +8 -0
  206. package/templates/vue/features/pinia/src/stores/user.ts +36 -0
  207. package/templates/vue/features/qiankun/package.json +5 -0
  208. package/templates/vue/features/qiankun/pnpm-workspace.yaml +3 -0
  209. package/templates/vue/features/qiankun/src/qiankun/index.ts +56 -0
  210. package/templates/vue/features/router/package.json +5 -0
  211. package/templates/vue/features/router/pnpm-workspace.yaml +3 -0
  212. package/templates/vue/features/sentry/package.json +6 -0
  213. package/templates/vue/features/sentry/pnpm-workspace.yaml +4 -0
  214. package/templates/vue/features/sentry/src/utils/sentry.ts +33 -0
  215. package/templates/vue/features/sentry/vite.config.data.ts +23 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * 应用入口文件
3
+ * 初始化 React 应用并挂载到 DOM
4
+ */
5
+
6
+ import React from 'react'
7
+ import ReactDOM from 'react-dom/client'
8
+ import { RouterProvider } from 'react-router-dom'
9
+ <% if (i18n) { -%>
10
+ import '@/locales'
11
+ <% } -%>
12
+ <% if (sentry) { -%>
13
+ import { initSentry } from '@/utils/sentry'
14
+ <% } -%>
15
+ import { createRouter } from '@/router'
16
+
17
+ // 导入样式文件
18
+ <% if (uiLibrary === 'ant-design') { -%>
19
+ import 'antd/dist/reset.css'
20
+ <% } -%>
21
+ import '@/assets/styles/main.scss'
22
+ import '@/assets/fonts/index.css'
23
+
24
+ <% if (sentry) { -%>
25
+ // 初始化 Sentry
26
+ initSentry({
27
+ dsn: import.meta.env.VITE_SENTRY_DSN,
28
+ environment: import.meta.env.MODE,
29
+ })
30
+
31
+ <% } -%>
32
+ const router = createRouter()
33
+
34
+ ReactDOM.createRoot(document.getElementById('root')!).render(
35
+ <React.StrictMode>
36
+ <RouterProvider router={router} />
37
+ </React.StrictMode>,
38
+ )
39
+
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 关于页面
3
+ */
4
+
5
+ function About(): JSX.Element {
6
+ return (
7
+ <div className="about-page">
8
+ <h1>关于</h1>
9
+ <p>这是关于页面</p>
10
+ </div>
11
+ )
12
+ }
13
+
14
+ export default About
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 首页
3
+ */
4
+
5
+ function Home(): JSX.Element {
6
+ return (
7
+ <div className="home-page">
8
+ <h1>欢迎使用 React Template</h1>
9
+ <p>这是一个基于 React + Vite + TypeScript 的项目模板</p>
10
+ </div>
11
+ )
12
+ }
13
+
14
+ export default Home
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 路由配置
3
+ */
4
+
5
+ import { createBrowserRouter, createHashRouter } from 'react-router-dom'
6
+ <% if (routeMode === 'file-system') { -%>
7
+ import routes from '~react-pages'
8
+ <% } else { -%>
9
+ import { routes } from './routes'
10
+ <% } -%>
11
+
12
+ interface RouterConfig {
13
+ historyMode?: 'hash' | 'history'
14
+ basename?: string
15
+ }
16
+
17
+ export function createRouter(config: RouterConfig = {}) {
18
+ const { historyMode = 'history', basename } = config
19
+
20
+ if (historyMode === 'hash') {
21
+ return createHashRouter(routes, { basename })
22
+ }
23
+
24
+ return createBrowserRouter(routes, { basename })
25
+ }
26
+
27
+ export { routes }
28
+
@@ -0,0 +1,39 @@
1
+ /**
2
+ * 用户状态管理
3
+ * 基于 Zustand
4
+ */
5
+
6
+ import { create } from 'zustand'
7
+ import { persist } from 'zustand/middleware'
8
+
9
+ interface UserInfo {
10
+ id: string
11
+ username: string
12
+ email: string
13
+ avatar?: string
14
+ roles: string[]
15
+ }
16
+
17
+ interface UserState {
18
+ userInfo: UserInfo | null
19
+ token: string
20
+ setUserInfo: (info: UserInfo | null) => void
21
+ setToken: (token: string) => void
22
+ clearUser: () => void
23
+ }
24
+
25
+ export const useUserStore = create<UserState>()(
26
+ persist(
27
+ set => ({
28
+ userInfo: null,
29
+ token: '',
30
+ setUserInfo: info => set({ userInfo: info }),
31
+ setToken: token => set({ token }),
32
+ clearUser: () => set({ userInfo: null, token: '' }),
33
+ }),
34
+ {
35
+ name: 'user-storage',
36
+ partialize: state => ({ token: state.token }),
37
+ },
38
+ ),
39
+ )
@@ -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/**/*.tsx"
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": "react-jsx",
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,12 @@
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ {
5
+ "path": "./tsconfig.app.json"
6
+ },
7
+ {
8
+ "path": "./tsconfig.node.json"
9
+ }
10
+ ]
11
+ }
12
+
@@ -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,52 @@
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
+ react: true,
26
+ viteConfig: {
27
+ plugins: [],
28
+ server: {
29
+ proxy: {
30
+ '/api': {
31
+ changeOrigin: true,
32
+ target: 'http://localhost:3000',
33
+ },
34
+ },
35
+ },
36
+ css: {
37
+ postcss: {
38
+ plugins: [
39
+ cssModuleGlobalRootPlugin,
40
+ ],
41
+ },
42
+ preprocessorOptions: {
43
+ scss: {
44
+ silenceDeprecations: ['legacy-js-api'],
45
+ api: 'modern-compiler',
46
+ },
47
+ },
48
+ },
49
+ },
50
+ }
51
+ },
52
+ )
@@ -0,0 +1,7 @@
1
+ {
2
+ "dependencies": {
3
+ "@ant-design/icons": "catalog:build",
4
+ "antd": "catalog:build"
5
+ }
6
+ }
7
+
@@ -0,0 +1,5 @@
1
+ catalogs:
2
+ build:
3
+ "@ant-design/icons": ^5.5.1
4
+ antd: ^5.22.0
5
+
@@ -0,0 +1,12 @@
1
+ import eslintConfig from '@moluoxixi/eslint-config'
2
+
3
+ export default eslintConfig({
4
+ react: true,
5
+ typescript: true,
6
+ ignores: [],
7
+ rules: {
8
+ 'perfectionist/sort-imports': 'off',
9
+ 'jsonc/sort-keys': 'off',
10
+ },
11
+ })
12
+
@@ -0,0 +1,7 @@
1
+ {
2
+ "devDependencies": {
3
+ "@moluoxixi/eslint-config": "catalog:dev",
4
+ "eslint": "catalog:dev",
5
+ "eslint-plugin-format": "catalog:dev"
6
+ }
7
+ }
@@ -0,0 +1,6 @@
1
+ catalogs:
2
+ dev:
3
+ '@moluoxixi/eslint-config': latest
4
+ eslint: ^9.22.0
5
+ eslint-plugin-format: ^1.0.1
6
+
@@ -0,0 +1,7 @@
1
+ {
2
+ "dependencies": {
3
+ "i18next": "catalog:build",
4
+ "react-i18next": "catalog:build"
5
+ }
6
+ }
7
+
@@ -0,0 +1,5 @@
1
+ catalogs:
2
+ build:
3
+ i18next: ^24.0.0
4
+ react-i18next: ^15.1.0
5
+
@@ -0,0 +1,20 @@
1
+ import i18n from 'i18next'
2
+ import { initReactI18next } from 'react-i18next'
3
+
4
+ import en from './lang/en'
5
+ import zh from './lang/zh'
6
+
7
+ i18n.use(initReactI18next).init({
8
+ resources: {
9
+ zh: { translation: zh },
10
+ en: { translation: en },
11
+ },
12
+ lng: localStorage.getItem('locale') || 'zh',
13
+ fallbackLng: 'zh',
14
+ interpolation: {
15
+ escapeValue: false,
16
+ },
17
+ })
18
+
19
+ export default i18n
20
+
@@ -0,0 +1,21 @@
1
+ import type { RouteObject } from 'react-router-dom'
2
+ import { lazy, Suspense } from 'react'
3
+
4
+ const Home = lazy(() => import('@/pages/home'))
5
+ const About = lazy(() => import('@/pages/about'))
6
+
7
+ function LazyLoad({ children }: { children: React.ReactNode }) {
8
+ return <Suspense fallback={<div>Loading...</div>}>{children}</Suspense>
9
+ }
10
+
11
+ export const routes: RouteObject[] = [
12
+ {
13
+ path: '/',
14
+ element: <LazyLoad><Home /></LazyLoad>,
15
+ },
16
+ {
17
+ path: '/about',
18
+ element: <LazyLoad><About /></LazyLoad>,
19
+ },
20
+ ]
21
+
@@ -0,0 +1,6 @@
1
+ {
2
+ "dependencies": {
3
+ "vite-plugin-pages": "catalog:build"
4
+ }
5
+ }
6
+
@@ -0,0 +1,4 @@
1
+ catalogs:
2
+ build:
3
+ vite-plugin-pages: ^0.32.4
4
+
@@ -0,0 +1,10 @@
1
+ import type { ViteConfigData } from '../../../../src/types/viteConfig'
2
+
3
+ const data: ViteConfigData = {
4
+ options: {
5
+ pageRoutes: true,
6
+ },
7
+ }
8
+
9
+ export default data
10
+
@@ -0,0 +1,5 @@
1
+ {
2
+ "dependencies": {
3
+ "react-router-dom": "catalog:build"
4
+ }
5
+ }
@@ -0,0 +1,3 @@
1
+ catalogs:
2
+ build:
3
+ react-router-dom: ^6.28.0
@@ -0,0 +1,7 @@
1
+ {
2
+ "dependencies": {
3
+ "@sentry/react": "catalog:build",
4
+ "@sentry/vite-plugin": "catalog:build"
5
+ }
6
+ }
7
+
@@ -0,0 +1,5 @@
1
+ catalogs:
2
+ build:
3
+ "@sentry/react": ^9.27.0
4
+ "@sentry/vite-plugin": ^3.5.0
5
+
@@ -0,0 +1,30 @@
1
+ import * as Sentry from '@sentry/react'
2
+
3
+ interface SentryConfig {
4
+ dsn: string
5
+ environment?: string
6
+ release?: string
7
+ }
8
+
9
+ export function initSentry(config: SentryConfig): void {
10
+ const { dsn, environment = 'production', release } = config
11
+
12
+ if (!dsn) {
13
+ console.warn('[Sentry] DSN is not configured, skipping initialization')
14
+ return
15
+ }
16
+
17
+ Sentry.init({
18
+ dsn,
19
+ environment,
20
+ release,
21
+ integrations: [
22
+ Sentry.browserTracingIntegration(),
23
+ Sentry.replayIntegration(),
24
+ ],
25
+ tracesSampleRate: 1.0,
26
+ replaysSessionSampleRate: 0.1,
27
+ replaysOnErrorSampleRate: 1.0,
28
+ })
29
+ }
30
+
@@ -0,0 +1,23 @@
1
+ import type { ViteConfigData } from '../../../../src/types/viteConfig'
2
+
3
+ const data: ViteConfigData = {
4
+ imports: [
5
+ 'import { sentryVitePlugin } from \'@sentry/vite-plugin\'',
6
+ ],
7
+ plugins: [
8
+ `viteEnv.VITE_SENTRY && mode === 'production' && sentryVitePlugin({
9
+ authToken: process.env.SENTRY_AUTH_TOKEN,
10
+ org: 'f1f562b9b82f',
11
+ project: 'javascript-react',
12
+ sourcemaps: {
13
+ assets: './dist/**',
14
+ ignore: ['node_modules'],
15
+ },
16
+ release: {
17
+ name: viteEnv.VITE_APP_VERSION || 'unknown',
18
+ },
19
+ })`,
20
+ ],
21
+ }
22
+
23
+ export default data
@@ -0,0 +1,5 @@
1
+ {
2
+ "dependencies": {
3
+ "zustand": "catalog:build"
4
+ }
5
+ }
@@ -0,0 +1,3 @@
1
+ catalogs:
2
+ build:
3
+ zustand: ^5.0.0
@@ -0,0 +1,19 @@
1
+ import type { UserStateType } from '@/types/stores'
2
+
3
+ import { create } from 'zustand'
4
+ import { persist } from 'zustand/middleware'
5
+
6
+ export const useUserStore = create<UserStateType>()(
7
+ persist(
8
+ set => ({
9
+ token: '',
10
+ userInfo: null,
11
+ setToken: (token: string) => set({ token }),
12
+ setUserInfo: (userInfo) => set({ userInfo }),
13
+ logout: () => set({ token: '', userInfo: null }),
14
+ }),
15
+ {
16
+ name: 'user-storage',
17
+ },
18
+ ),
19
+ )
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Store 类型定义
3
+ */
4
+
5
+ import type { UserInfoType } from '@/apis/types/user'
6
+
7
+ /** 用户 Store 状态类型 */
8
+ export interface UserStateType {
9
+ token: string
10
+ userInfo: UserInfoType | null
11
+ setToken: (token: string) => void
12
+ setUserInfo: (info: UserInfoType) => void
13
+ logout: () => void
14
+ }
15
+
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 环境变量类型声明
3
+ */
4
+
5
+ /// <reference types="vite/client" />
6
+
7
+ interface ImportMetaEnv {
8
+ readonly VITE_APP_CODE: string;
9
+ readonly VITE_APP_TITLE: string;
10
+ readonly VITE_APP_PORT: number;
11
+ readonly VITE_APP_VERSION: string;
12
+ readonly VITE_APP_ENV: string;
13
+ readonly VITE_API_BASE_URL: string;
14
+ readonly VITE_SENTRY: boolean;
15
+ }
16
+
17
+ interface ImportMeta {
18
+ readonly env: ImportMetaEnv;
19
+ }
20
+
21
+ declare module '*.vue' {
22
+ import type { DefineComponent } from 'vue';
23
+
24
+ const component: DefineComponent<object, object, unknown>;
25
+ export default component;
26
+ }
27
+
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>%VITE_APP_TITLE%</title>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="/src/main.ts"></script>
12
+ </body>
13
+ </html>
14
+
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "vue-project",
3
+ "scripts": {
4
+ "type-check": "vue-tsc --noEmit"
5
+ },
6
+ "dependencies": {
7
+ "vue": "catalog:build"
8
+ },
9
+ "devDependencies": {
10
+ "@vue-macros/volar": "catalog:dev",
11
+ "vue-tsc": "catalog:dev"
12
+ }
13
+ }
@@ -0,0 +1,6 @@
1
+ catalogs:
2
+ build:
3
+ vue: ^3.5.13
4
+ dev:
5
+ "@vue-macros/volar": ^3.0.0-beta.15
6
+ vue-tsc: ^2.2.8
@@ -0,0 +1,13 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * 根组件
4
+ */
5
+ </script>
6
+
7
+ <template>
8
+ <RouterView />
9
+ </template>
10
+
11
+ <style scoped>
12
+ </style>
13
+
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Element Plus 样式定制
3
+ * 自定义 Element Plus 主题
4
+ */
5
+
6
+ @forward 'element-plus/theme-chalk/src/common/var.scss' with (
7
+ $colors: (
8
+ 'primary': (
9
+ 'base': #409eff,
10
+ ),
11
+ 'success': (
12
+ 'base': #67c23a,
13
+ ),
14
+ 'warning': (
15
+ 'base': #e6a23c,
16
+ ),
17
+ 'danger': (
18
+ 'base': #f56c6c,
19
+ ),
20
+ 'info': (
21
+ 'base': #909399,
22
+ ),
23
+ ),
24
+ );
25
+
26
+ @use 'element-plus/theme-chalk/src/index.scss' as *;
27
+
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 主样式文件
3
+ * 导入所有样式
4
+ */
5
+
6
+ @import './base.scss';
7
+ @import './custom.scss';
8
+ @import './tailwind.scss';
9
+
@@ -0,0 +1,9 @@
1
+ /**
2
+ * SubMenu 组件导出
3
+ */
4
+
5
+ import SubMenu from './src/index.vue';
6
+
7
+ export { SubMenu };
8
+ export default SubMenu;
9
+
@@ -0,0 +1,6 @@
1
+ /**
2
+ * SubMenu 类型导出
3
+ */
4
+
5
+ export * from './props';
6
+