@4399ywkf/cli 1.0.7 → 1.0.9

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 (254) hide show
  1. package/dist/templates/AntdStaticMethods/index.tsx +20 -0
  2. package/dist/templates/AppTheme.tsx +136 -0
  3. package/dist/templates/DIRECTORY_STRUCTURE.md +141 -0
  4. package/dist/templates/GlobalProvider/AppTheme.tsx +136 -0
  5. package/dist/templates/GlobalProvider/Locale.tsx +84 -0
  6. package/dist/templates/GlobalProvider/Query.tsx +12 -0
  7. package/dist/templates/GlobalProvider/StyleRegistry.tsx +9 -0
  8. package/dist/templates/GlobalProvider/index.tsx +23 -0
  9. package/dist/templates/HarmonyOS_Sans_Bold.woff2 +0 -0
  10. package/dist/templates/HarmonyOS_Sans_Medium.woff2 +0 -0
  11. package/dist/templates/HarmonyOS_Sans_Regular.woff2 +0 -0
  12. package/dist/templates/Locale.tsx +49 -54
  13. package/dist/templates/MainContentWrap.tsx +11 -15
  14. package/dist/templates/Query.tsx +12 -0
  15. package/dist/templates/StyleRegistry.tsx +9 -0
  16. package/dist/templates/ThemeContext.tsx +27 -24
  17. package/dist/templates/analyzeUnusedKeys.ts +506 -0
  18. package/dist/templates/app/.i18nrc.js +57 -0
  19. package/dist/templates/app/config/env/.env.public.tpl +2 -19
  20. package/dist/templates/app/config/jwt/index.ts +4 -4
  21. package/dist/templates/app/config/request/error-handler.ts +67 -0
  22. package/dist/templates/app/config/request/index.ts +127 -129
  23. package/dist/templates/app/config/request/interceptors.ts +118 -0
  24. package/dist/templates/app/config/request/token-manager.ts +23 -0
  25. package/dist/templates/app/config/request/types.ts +63 -0
  26. package/dist/templates/app/config/rspack/rspack.config.mjs +62 -61
  27. package/dist/templates/app/config/rspack/rspack.prod.mjs +41 -62
  28. package/dist/templates/app/docs/DIRECTORY_STRUCTURE.md +141 -0
  29. package/dist/templates/app/docs/glossary.md +11 -0
  30. package/dist/templates/app/locales/zh-CN/common.json +3 -0
  31. package/dist/templates/app/package.json.tpl +8 -25
  32. package/dist/templates/app/public/fonts/HarmonyOS_Sans_Bold.woff2 +0 -0
  33. package/dist/templates/app/public/fonts/HarmonyOS_Sans_Medium.woff2 +0 -0
  34. package/dist/templates/app/public/fonts/HarmonyOS_Sans_Regular.woff2 +0 -0
  35. package/dist/templates/app/react-app-env.d.ts +13 -8
  36. package/dist/templates/app/scripts/i18nWorkflow/analyzeUnusedKeys.ts +506 -0
  37. package/dist/templates/app/scripts/i18nWorkflow/cleanUnusedKeys.ts +344 -0
  38. package/dist/templates/app/scripts/i18nWorkflow/const.ts +18 -0
  39. package/dist/templates/app/scripts/i18nWorkflow/flattenLocaleKeys.ts +139 -0
  40. package/dist/templates/app/scripts/i18nWorkflow/genDefaultLocale.ts +19 -0
  41. package/dist/templates/app/scripts/i18nWorkflow/genDiff.ts +49 -0
  42. package/dist/templates/app/scripts/i18nWorkflow/i18nConfig.ts +7 -0
  43. package/dist/templates/app/scripts/i18nWorkflow/index.ts +11 -0
  44. package/dist/templates/app/scripts/i18nWorkflow/protectedPatterns.ts +91 -0
  45. package/dist/templates/app/scripts/i18nWorkflow/utils.ts +76 -0
  46. package/dist/templates/app/src/bootstrap/index.ts +34 -0
  47. package/dist/templates/app/src/components/AntdStaticMethods/index.tsx +20 -0
  48. package/dist/templates/app/src/config/env.ts +84 -0
  49. package/dist/templates/app/src/index.tsx +13 -51
  50. package/dist/templates/app/src/layout/GlobalProvider/AppTheme.tsx +136 -0
  51. package/dist/templates/app/src/layout/GlobalProvider/Locale.tsx +84 -0
  52. package/dist/templates/app/src/layout/GlobalProvider/Query.tsx +12 -0
  53. package/dist/templates/app/src/layout/GlobalProvider/StyleRegistry.tsx +9 -0
  54. package/dist/templates/app/src/layout/GlobalProvider/index.tsx +23 -0
  55. package/dist/templates/app/src/layout/Locale.tsx +14 -18
  56. package/dist/templates/app/src/layout/MainContentWrap.tsx +11 -15
  57. package/dist/templates/app/src/layout/ThemeContext.tsx +27 -24
  58. package/dist/templates/app/src/locales/default/common.ts +3 -1
  59. package/dist/templates/app/src/locales/utils.ts +23 -0
  60. package/dist/templates/app/src/micro/garfish.ts +53 -0
  61. package/dist/templates/app/src/pages/base/index.tsx +280 -25
  62. package/dist/templates/app/src/routes.tsx +21 -12
  63. package/dist/templates/app/src/types/global.d.ts +19 -0
  64. package/dist/templates/app/src/utils/index.ts +3 -1
  65. package/dist/templates/app/store/middleware/createDevtools.ts +7 -7
  66. package/dist/templates/app/tsconfig.json +19 -3
  67. package/dist/templates/base/index.tsx +280 -25
  68. package/dist/templates/bootstrap/index.ts +34 -0
  69. package/dist/templates/cleanUnusedKeys.ts +344 -0
  70. package/dist/templates/common.json +3 -0
  71. package/dist/templates/common.ts +3 -1
  72. package/dist/templates/components/AntdStaticMethods/index.tsx +20 -0
  73. package/dist/templates/config/env/.env.public.tpl +2 -19
  74. package/dist/templates/config/env.ts +84 -0
  75. package/dist/templates/config/jwt/index.ts +4 -4
  76. package/dist/templates/config/request/error-handler.ts +67 -0
  77. package/dist/templates/config/request/index.ts +127 -129
  78. package/dist/templates/config/request/interceptors.ts +118 -0
  79. package/dist/templates/config/request/token-manager.ts +23 -0
  80. package/dist/templates/config/request/types.ts +63 -0
  81. package/dist/templates/config/rspack/rspack.config.mjs +62 -61
  82. package/dist/templates/config/rspack/rspack.prod.mjs +41 -62
  83. package/dist/templates/const.ts +18 -0
  84. package/dist/templates/createDevtools.ts +7 -7
  85. package/dist/templates/default/common.ts +3 -1
  86. package/dist/templates/docs/DIRECTORY_STRUCTURE.md +141 -0
  87. package/dist/templates/docs/glossary.md +11 -0
  88. package/dist/templates/env/.env.public.tpl +2 -19
  89. package/dist/templates/env.ts +83 -2
  90. package/dist/templates/error-handler.ts +67 -0
  91. package/dist/templates/flattenLocaleKeys.ts +139 -0
  92. package/dist/templates/fonts/HarmonyOS_Sans_Bold.woff2 +0 -0
  93. package/dist/templates/fonts/HarmonyOS_Sans_Medium.woff2 +0 -0
  94. package/dist/templates/fonts/HarmonyOS_Sans_Regular.woff2 +0 -0
  95. package/dist/templates/garfish.ts +53 -0
  96. package/dist/templates/genDefaultLocale.ts +19 -0
  97. package/dist/templates/genDiff.ts +49 -0
  98. package/dist/templates/global.d.ts +19 -0
  99. package/dist/templates/glossary.md +11 -0
  100. package/dist/templates/i18nConfig.ts +7 -0
  101. package/dist/templates/i18nWorkflow/analyzeUnusedKeys.ts +506 -0
  102. package/dist/templates/i18nWorkflow/cleanUnusedKeys.ts +344 -0
  103. package/dist/templates/i18nWorkflow/const.ts +18 -0
  104. package/dist/templates/i18nWorkflow/flattenLocaleKeys.ts +139 -0
  105. package/dist/templates/i18nWorkflow/genDefaultLocale.ts +19 -0
  106. package/dist/templates/i18nWorkflow/genDiff.ts +49 -0
  107. package/dist/templates/i18nWorkflow/i18nConfig.ts +7 -0
  108. package/dist/templates/i18nWorkflow/index.ts +11 -0
  109. package/dist/templates/i18nWorkflow/protectedPatterns.ts +91 -0
  110. package/dist/templates/i18nWorkflow/utils.ts +76 -0
  111. package/dist/templates/index.tsx +280 -25
  112. package/dist/templates/interceptors.ts +118 -0
  113. package/dist/templates/jwt/index.ts +4 -4
  114. package/dist/templates/layout/GlobalProvider/AppTheme.tsx +136 -0
  115. package/dist/templates/layout/GlobalProvider/Locale.tsx +84 -0
  116. package/dist/templates/layout/GlobalProvider/Query.tsx +12 -0
  117. package/dist/templates/layout/GlobalProvider/StyleRegistry.tsx +9 -0
  118. package/dist/templates/layout/GlobalProvider/index.tsx +23 -0
  119. package/dist/templates/layout/Locale.tsx +14 -18
  120. package/dist/templates/layout/MainContentWrap.tsx +11 -15
  121. package/dist/templates/layout/ThemeContext.tsx +27 -24
  122. package/dist/templates/locales/default/common.ts +3 -1
  123. package/dist/templates/locales/utils.ts +23 -0
  124. package/dist/templates/locales/zh-CN/common.json +3 -0
  125. package/dist/templates/micro/garfish.ts +53 -0
  126. package/dist/templates/middleware/createDevtools.ts +7 -7
  127. package/dist/templates/package.json.tpl +8 -25
  128. package/dist/templates/page.tsx +21 -19
  129. package/dist/templates/pages/base/index.tsx +280 -25
  130. package/dist/templates/protectedPatterns.ts +91 -0
  131. package/dist/templates/public/fonts/HarmonyOS_Sans_Bold.woff2 +0 -0
  132. package/dist/templates/public/fonts/HarmonyOS_Sans_Medium.woff2 +0 -0
  133. package/dist/templates/public/fonts/HarmonyOS_Sans_Regular.woff2 +0 -0
  134. package/dist/templates/react-app-env.d.ts +13 -8
  135. package/dist/templates/request/error-handler.ts +67 -0
  136. package/dist/templates/request/index.ts +127 -129
  137. package/dist/templates/request/interceptors.ts +118 -0
  138. package/dist/templates/request/token-manager.ts +23 -0
  139. package/dist/templates/request/types.ts +63 -0
  140. package/dist/templates/routes.tsx +21 -12
  141. package/dist/templates/rspack/rspack.config.mjs +62 -61
  142. package/dist/templates/rspack/rspack.prod.mjs +41 -62
  143. package/dist/templates/rspack.config.mjs +62 -61
  144. package/dist/templates/rspack.prod.mjs +41 -62
  145. package/dist/templates/scripts/i18nWorkflow/analyzeUnusedKeys.ts +506 -0
  146. package/dist/templates/scripts/i18nWorkflow/cleanUnusedKeys.ts +344 -0
  147. package/dist/templates/scripts/i18nWorkflow/const.ts +18 -0
  148. package/dist/templates/scripts/i18nWorkflow/flattenLocaleKeys.ts +139 -0
  149. package/dist/templates/scripts/i18nWorkflow/genDefaultLocale.ts +19 -0
  150. package/dist/templates/scripts/i18nWorkflow/genDiff.ts +49 -0
  151. package/dist/templates/scripts/i18nWorkflow/i18nConfig.ts +7 -0
  152. package/dist/templates/scripts/i18nWorkflow/index.ts +11 -0
  153. package/dist/templates/scripts/i18nWorkflow/protectedPatterns.ts +91 -0
  154. package/dist/templates/scripts/i18nWorkflow/utils.ts +76 -0
  155. package/dist/templates/src/bootstrap/index.ts +34 -0
  156. package/dist/templates/src/components/AntdStaticMethods/index.tsx +20 -0
  157. package/dist/templates/src/config/env.ts +84 -0
  158. package/dist/templates/src/index.tsx +13 -51
  159. package/dist/templates/src/layout/GlobalProvider/AppTheme.tsx +136 -0
  160. package/dist/templates/src/layout/GlobalProvider/Locale.tsx +84 -0
  161. package/dist/templates/src/layout/GlobalProvider/Query.tsx +12 -0
  162. package/dist/templates/src/layout/GlobalProvider/StyleRegistry.tsx +9 -0
  163. package/dist/templates/src/layout/GlobalProvider/index.tsx +23 -0
  164. package/dist/templates/src/layout/Locale.tsx +14 -18
  165. package/dist/templates/src/layout/MainContentWrap.tsx +11 -15
  166. package/dist/templates/src/layout/ThemeContext.tsx +27 -24
  167. package/dist/templates/src/locales/default/common.ts +3 -1
  168. package/dist/templates/src/locales/utils.ts +23 -0
  169. package/dist/templates/src/micro/garfish.ts +53 -0
  170. package/dist/templates/src/pages/base/index.tsx +280 -25
  171. package/dist/templates/src/routes.tsx +21 -12
  172. package/dist/templates/src/types/global.d.ts +19 -0
  173. package/dist/templates/src/utils/index.ts +3 -1
  174. package/dist/templates/store/middleware/createDevtools.ts +7 -7
  175. package/dist/templates/token-manager.ts +23 -0
  176. package/dist/templates/tsconfig.json +19 -3
  177. package/dist/templates/type.ts +23 -24
  178. package/dist/templates/types/global.d.ts +19 -0
  179. package/dist/templates/utils/index.ts +3 -1
  180. package/dist/templates/utils.ts +23 -0
  181. package/dist/templates/zh-CN/common.json +3 -0
  182. package/package.json +19 -21
  183. package/dist/templates/app/config/sentry/sentry.config.ts +0 -188
  184. package/dist/templates/app/src/hooks/useRouteTitle.tsx +0 -36
  185. package/dist/templates/app/src/hooks/useSentry.ts +0 -92
  186. package/dist/templates/app/src/pages/base/layout.tsx +0 -6
  187. package/dist/templates/app/src/pages/base/page.tsx +0 -25
  188. package/dist/templates/app/src/utils/env.ts +0 -3
  189. package/dist/templates/app/src/utils/format.ts +0 -21
  190. package/dist/templates/app/src/utils/getMicroApp.ts +0 -39
  191. package/dist/templates/app/src/utils/sentry.ts +0 -187
  192. package/dist/templates/app/src/utils/sentryDecorators.ts +0 -34
  193. package/dist/templates/app/src/utils/updateVersion.ts +0 -186
  194. package/dist/templates/base/layout.tsx +0 -6
  195. package/dist/templates/base/page.tsx +0 -25
  196. package/dist/templates/config/public/404.png +0 -0
  197. package/dist/templates/config/public/favicon.ico +0 -0
  198. package/dist/templates/config/public/images/banner_market_modal.webp +0 -0
  199. package/dist/templates/config/public/images/chatmode_chat_dark.webp +0 -0
  200. package/dist/templates/config/public/images/chatmode_chat_light.webp +0 -0
  201. package/dist/templates/config/public/images/chatmode_docs_dark.webp +0 -0
  202. package/dist/templates/config/public/images/chatmode_docs_light.webp +0 -0
  203. package/dist/templates/config/public/images/empty_topic_dark.webp +0 -0
  204. package/dist/templates/config/public/images/empty_topic_light.webp +0 -0
  205. package/dist/templates/config/public/images/screenshot_background.webp +0 -0
  206. package/dist/templates/config/public/images/theme_auto.webp +0 -0
  207. package/dist/templates/config/public/images/theme_dark.webp +0 -0
  208. package/dist/templates/config/public/images/theme_light.webp +0 -0
  209. package/dist/templates/config/public/index.html +0 -29
  210. package/dist/templates/config/sentry/sentry.config.ts +0 -188
  211. package/dist/templates/format.ts +0 -21
  212. package/dist/templates/getMicroApp.ts +0 -39
  213. package/dist/templates/hooks/useRouteTitle.tsx +0 -36
  214. package/dist/templates/hooks/useSentry.ts +0 -92
  215. package/dist/templates/layout.tsx +0 -6
  216. package/dist/templates/pages/base/layout.tsx +0 -6
  217. package/dist/templates/pages/base/page.tsx +0 -25
  218. package/dist/templates/sentry/sentry.config.ts +0 -188
  219. package/dist/templates/sentry.config.ts +0 -188
  220. package/dist/templates/sentry.ts +0 -187
  221. package/dist/templates/sentryDecorators.ts +0 -34
  222. package/dist/templates/src/hooks/useRouteTitle.tsx +0 -36
  223. package/dist/templates/src/hooks/useSentry.ts +0 -92
  224. package/dist/templates/src/pages/base/layout.tsx +0 -6
  225. package/dist/templates/src/pages/base/page.tsx +0 -25
  226. package/dist/templates/src/utils/env.ts +0 -3
  227. package/dist/templates/src/utils/format.ts +0 -21
  228. package/dist/templates/src/utils/getMicroApp.ts +0 -39
  229. package/dist/templates/src/utils/sentry.ts +0 -187
  230. package/dist/templates/src/utils/sentryDecorators.ts +0 -34
  231. package/dist/templates/src/utils/updateVersion.ts +0 -186
  232. package/dist/templates/updateVersion.ts +0 -186
  233. package/dist/templates/useRouteTitle.tsx +0 -36
  234. package/dist/templates/useSentry.ts +0 -92
  235. package/dist/templates/utils/env.ts +0 -3
  236. package/dist/templates/utils/format.ts +0 -21
  237. package/dist/templates/utils/getMicroApp.ts +0 -39
  238. package/dist/templates/utils/sentry.ts +0 -187
  239. package/dist/templates/utils/sentryDecorators.ts +0 -34
  240. package/dist/templates/utils/updateVersion.ts +0 -186
  241. /package/dist/templates/app/{config/public → public}/404.png +0 -0
  242. /package/dist/templates/app/{config/public → public}/favicon.ico +0 -0
  243. /package/dist/templates/app/{config/public → public}/images/banner_market_modal.webp +0 -0
  244. /package/dist/templates/app/{config/public → public}/images/chatmode_chat_dark.webp +0 -0
  245. /package/dist/templates/app/{config/public → public}/images/chatmode_chat_light.webp +0 -0
  246. /package/dist/templates/app/{config/public → public}/images/chatmode_docs_dark.webp +0 -0
  247. /package/dist/templates/app/{config/public → public}/images/chatmode_docs_light.webp +0 -0
  248. /package/dist/templates/app/{config/public → public}/images/empty_topic_dark.webp +0 -0
  249. /package/dist/templates/app/{config/public → public}/images/empty_topic_light.webp +0 -0
  250. /package/dist/templates/app/{config/public → public}/images/screenshot_background.webp +0 -0
  251. /package/dist/templates/app/{config/public → public}/images/theme_auto.webp +0 -0
  252. /package/dist/templates/app/{config/public → public}/images/theme_dark.webp +0 -0
  253. /package/dist/templates/app/{config/public → public}/images/theme_light.webp +0 -0
  254. /package/dist/templates/app/{config/public → public}/index.html +0 -0
@@ -0,0 +1,76 @@
1
+ import { consola } from "consola";
2
+ import { colors } from "consola/utils";
3
+ import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
4
+ import { resolve, dirname } from "node:path";
5
+ import prettier from "@prettier/sync";
6
+ import i18nConfig from "./i18nConfig";
7
+
8
+ let prettierOptions = prettier.resolveConfig(
9
+ resolve(__dirname, "../../.prettierrc.js"),
10
+ );
11
+
12
+ export const readJSON = (filePath: string) => {
13
+ const data = readFileSync(filePath, "utf8");
14
+ return JSON.parse(data);
15
+ };
16
+
17
+ export const writeJSON = (filePath: string, data: any) => {
18
+ const jsonStr = JSON.stringify(data, null, 2);
19
+ writeFileSync(filePath, jsonStr, "utf8");
20
+ };
21
+
22
+ export const writeJSONWithPrettier = (filePath: string, data: any) => {
23
+ mkdirSync(dirname(filePath), { recursive: true });
24
+ const jsonStr = JSON.stringify(data, null, 2);
25
+ const formatted = prettier.format(jsonStr, {
26
+ ...prettierOptions,
27
+ parser: "json",
28
+ });
29
+ writeFileSync(filePath, formatted, "utf8");
30
+ };
31
+
32
+ export const genResourcesContent = (locales: string[]) => {
33
+ let index = "";
34
+ let indexObj = "";
35
+
36
+ for (const locale of locales) {
37
+ index += `import ${locale} from "./${locale}";\n`;
38
+ indexObj += ` "${locale.replace("_", "-")}": ${locale},\n`;
39
+ }
40
+
41
+ return `${index}
42
+ const resources = {
43
+ ${indexObj}} as const;
44
+ export default resources;
45
+ export const defaultResources = ${i18nConfig.entryLocale};
46
+ export type Resources = typeof resources;
47
+ export type DefaultResources = typeof defaultResources;
48
+ export type Namespaces = keyof DefaultResources;
49
+ export type Locales = keyof Resources;
50
+ `;
51
+ };
52
+
53
+ export const genNamespaceList = (files: string[], locale: string) => {
54
+ return files.map((file) => ({
55
+ name: file.replace(".json", ""),
56
+ path: resolve(i18nConfig.output, locale, file),
57
+ }));
58
+ };
59
+
60
+ export const tagBlue = (text: string) =>
61
+ colors.bgBlueBright(colors.black(` ${text} `));
62
+ export const tagYellow = (text: string) =>
63
+ colors.bgYellowBright(colors.black(` ${text} `));
64
+ export const tagGreen = (text: string) =>
65
+ colors.bgGreenBright(colors.black(` ${text} `));
66
+ export const tagWhite = (text: string) =>
67
+ colors.bgWhiteBright(colors.black(` ${text} `));
68
+
69
+ export const split = (name: string) => {
70
+ consola.log("");
71
+ consola.log(
72
+ colors.gray(
73
+ `========================== ${name} ==============================`,
74
+ ),
75
+ );
76
+ };
@@ -1,32 +1,287 @@
1
- import React from 'react';
2
- import { createStyles } from "antd-style"
3
-
4
-
5
- const useStyles = createStyles(({ token, isDarkMode }) => ({
6
- button: {
7
- backgroundColor: token.colorPrimary,
8
- width: '100px',
9
- color: isDarkMode ? token.colorText : "#fff",
10
- padding: `${token.paddingXS}px ${token.paddingSM}px`,
11
- borderRadius: token.borderRadius,
12
- cursor: 'pointer',
13
- transition: 'all 0.3s ease',
14
-
15
- '&:hover': {
16
- backgroundColor: token.colorPrimaryHover,
1
+ import { useUserStore } from "@store/user";
2
+ import { Button, Card, Space, Typography, Tag, Flex } from "antd";
3
+ import {
4
+ RocketOutlined,
5
+ ThunderboltOutlined,
6
+ BulbOutlined,
7
+ GithubOutlined,
8
+ BookOutlined,
9
+ SettingOutlined,
10
+ } from "@ant-design/icons";
11
+ import React from "react";
12
+ import { createStyles } from "antd-style";
13
+
14
+ const { Title, Paragraph, Text } = Typography;
15
+
16
+ const px = (value: number | string) =>
17
+ typeof value === "number" ? `${value}px` : value;
18
+
19
+ const useStyles = createStyles(({ token, css }) => ({
20
+ root: css`
21
+ width: 100%;
22
+ min-height: 100vh;
23
+ padding: ${px(token.paddingLG)};
24
+ background: linear-gradient(180deg, ${token.colorFillTertiary}, ${token.colorPrimaryHover});
25
+ overflow: auto;
26
+ `,
27
+ container: css`
28
+ margin: 0 auto;
29
+ max-width: 960px;
30
+ `,
31
+ hero: css`
32
+ text-align: center;
33
+ margin-bottom: ${px(token.marginLG)};
34
+ `,
35
+ heroIcon: css`
36
+ font-size: 3.5rem;
37
+ color: ${token.colorPrimary};
38
+ animation: bounce 1.2s infinite alternate;
39
+
40
+ @keyframes bounce {
41
+ from {
42
+ transform: translateY(0);
43
+ }
44
+ to {
45
+ transform: translateY(-6px);
46
+ }
47
+ }
48
+ `,
49
+ tagSpace: css`
50
+ margin-top: ${px(token.marginMD)};
51
+ `,
52
+ featuresGrid: css`
53
+ display: grid;
54
+ grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
55
+ gap: ${px(token.marginSM)};
56
+ margin-bottom: ${px(token.marginLG)};
57
+ `,
58
+ featureCard: css`
59
+ text-align: center;
60
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
61
+
62
+ &:hover {
63
+ transform: translateY(-6px);
64
+ box-shadow: ${token.boxShadowSecondary};
65
+ }
66
+ `,
67
+ quickLinkGrid: css`
68
+ display: grid;
69
+ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
70
+ gap: ${px(token.marginSM)};
71
+ `,
72
+ quickLink: css`
73
+ padding: ${px(token.paddingMD)};
74
+ border-radius: ${px(token.borderRadiusLG)};
75
+ background: ${token.colorBgContainer};
76
+ cursor: pointer;
77
+ transition: background 0.2s ease;
78
+
79
+ &:hover {
80
+ background: ${token.colorBgElevated};
81
+ }
82
+ `,
83
+ footerActions: css`
84
+ margin-top: ${px(token.marginMD)};
85
+ text-align: center;
86
+ `,
87
+ cardTitle: css`
88
+ display: inline-flex;
89
+ align-items: center;
90
+ gap: ${px(token.marginXS)};
91
+ font-size: ${px(token.fontSizeHeading4)};
92
+ `,
93
+ codeBlock: css`
94
+ margin-top: ${px(token.marginXS)};
95
+ padding: ${px(token.paddingSM)};
96
+ background: ${token.colorFillAlter};
97
+ border-radius: ${px(token.borderRadiusLG)};
98
+ font-family: ${token.fontFamilyCode};
99
+ font-size: ${px(token.fontSizeSM)};
100
+ `,
101
+ stepLabel: css`
102
+ font-size: ${px(token.fontSizeBase)};
103
+ `,
104
+ quickLinkLabel: css`
105
+ font-size: ${px(token.fontSizeHeading2)};
106
+ margin-bottom: ${px(token.marginXS)};
107
+ `,
108
+ quickLinkDescription: css`
109
+ color: ${token.colorTextTertiary};
110
+ `,
111
+ panelCard: css`
112
+ margin-bottom: ${px(token.marginLG)};
113
+ background: ${token.colorBgElevated};
114
+ `,
115
+ featureIcon: css`
116
+ margin-bottom: ${px(token.marginMD)};
117
+ `,
118
+ footerParagraph: css`
119
+ margin-top: ${px(token.marginMD)};
120
+ color: ${token.colorTextTertiary};
121
+ `,
122
+ textCenterCard: css`
123
+ text-align: center;
124
+ `,
125
+ }));
126
+
127
+ export default function BasePage() {
128
+ const theme = useUserStore((state) => state.themeMode);
129
+ const setTheme = useUserStore((state) => state.setThemeMode);
130
+ const { styles, cx } = useStyles();
131
+
132
+ const features = [
133
+ {
134
+ icon: <ThunderboltOutlined className={styles.heroIcon} />,
135
+ title: "Rspack 构建",
136
+ description: "基于 Rspack 的极速构建体验,开发效率翻倍",
17
137
  },
18
- '&:active': {
19
- backgroundColor: token.colorPrimaryActive,
138
+ {
139
+ icon: <BulbOutlined className={styles.heroIcon} />,
140
+ title: "React 19",
141
+ description: "使用最新的 React 19 特性,享受并发渲染",
20
142
  },
21
- },
22
- }));
143
+ {
144
+ icon: <SettingOutlined className={styles.heroIcon} />,
145
+ title: "TypeScript",
146
+ description: "完整的 TypeScript 支持,类型安全有保障",
147
+ },
148
+ ];
149
+
150
+ const quickLinks = [
151
+ { label: "📖 文档", description: "查看完整文档" },
152
+ { label: "🎨 组件库", description: "Ant Design 组件" },
153
+ { label: "🔧 配置", description: "项目配置说明" },
154
+ { label: "🚀 部署", description: "部署指南" },
155
+ ];
23
156
 
24
- export default function Base() {
25
- const { styles } = useStyles();
26
157
  return (
27
- <div className={styles.button}>
28
- Base
29
- {/* <Button type="primary">antd按钮</Button> */}
158
+ <div className={cx(styles.root)}>
159
+ <div className={styles.container}>
160
+ <Flex vertical gap={12}>
161
+ <section className={styles.hero}>
162
+ <div>
163
+ <RocketOutlined className={styles.heroIcon} />
164
+ </div>
165
+ <Title level={1} style={{ marginBottom: 16 }}>
166
+ 🎉 恭喜!项目创建成功
167
+ </Title>
168
+ <Paragraph>
169
+ 你的项目已经准备就绪,现在可以开始开发了
170
+ </Paragraph>
171
+ <Space size="middle" className={styles.tagSpace}>
172
+ <Tag color="blue">React 19</Tag>
173
+ <Tag color="green">TypeScript</Tag>
174
+ <Tag color="orange">Rspack</Tag>
175
+ <Tag color="purple">Ant Design</Tag>
176
+ <Tag color="cyan">Tailwind CSS</Tag>
177
+ </Space>
178
+ </section>
179
+
180
+ <div className={styles.featuresGrid}>
181
+ {features.map((feature, index) => (
182
+ <Card
183
+ key={index}
184
+ hoverable
185
+ className={cx(styles.featureCard)}
186
+ bodyStyle={{ padding: 24 }}
187
+ >
188
+ <div className={styles.featureIcon}>{feature.icon}</div>
189
+ <Title level={4}>{feature.title}</Title>
190
+ <Paragraph type="secondary">{feature.description}</Paragraph>
191
+ </Card>
192
+ ))}
193
+ </div>
194
+
195
+ <Card
196
+ title={
197
+ <span className={styles.cardTitle}>
198
+ <BookOutlined />
199
+ 快速开始
200
+ </span>
201
+ }
202
+ className={styles.panelCard}
203
+ >
204
+ <Space direction="vertical" size="large">
205
+ <div>
206
+ <Text strong className={styles.stepLabel}>
207
+ 1. 安装依赖
208
+ </Text>
209
+ <div className={styles.codeBlock}>
210
+ <code>pnpm install</code>
211
+ </div>
212
+ </div>
213
+ <div>
214
+ <Text strong className={styles.stepLabel}>
215
+ 2. 启动开发服务器
216
+ </Text>
217
+ <div className={styles.codeBlock}>
218
+ <code>pnpm dev</code>
219
+ </div>
220
+ </div>
221
+ <div>
222
+ <Text strong className={styles.stepLabel}>
223
+ 3. 构建生产版本
224
+ </Text>
225
+ <div className={styles.codeBlock}>
226
+ <code>pnpm build</code>
227
+ </div>
228
+ </div>
229
+ </Space>
230
+ </Card>
231
+
232
+ <Card
233
+ title={
234
+ <span className={styles.cardTitle}>
235
+ <GithubOutlined />
236
+ 快捷链接
237
+ </span>
238
+ }
239
+ className={styles.panelCard}
240
+ >
241
+ <div className={styles.quickLinkGrid}>
242
+ {quickLinks.map((link, index) => (
243
+ <div key={index} className={styles.quickLink}>
244
+ <div className={styles.quickLinkLabel}>{link.label}</div>
245
+ <Text className={styles.quickLinkDescription}>
246
+ {link.description}
247
+ </Text>
248
+ </div>
249
+ ))}
250
+ </div>
251
+ </Card>
252
+
253
+ <Card className={cx(styles.panelCard, styles.textCenterCard)}>
254
+ <div className={styles.footerActions}>
255
+ <Space size="large" wrap>
256
+ <Button
257
+ type="primary"
258
+ size="large"
259
+ icon={<RocketOutlined />}
260
+ onClick={() => window.open("https://ant.design", "_blank")}
261
+ >
262
+ 查看 Ant Design 文档
263
+ </Button>
264
+ <Button
265
+ size="large"
266
+ icon={<BookOutlined />}
267
+ onClick={() => window.open("https://react.dev", "_blank")}
268
+ >
269
+ React 文档
270
+ </Button>
271
+ <Button
272
+ size="large"
273
+ onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
274
+ >
275
+ 切换主题 ({theme === "dark" ? "🌙 暗色" : "☀️ 亮色"})
276
+ </Button>
277
+ </Space>
278
+ <Paragraph className={styles.footerParagraph}>
279
+ 祝你开发愉快!如有问题,请查阅文档或联系技术支持 💪
280
+ </Paragraph>
281
+ </div>
282
+ </Card>
283
+ </Flex>
284
+ </div>
30
285
  </div>
31
286
  );
32
287
  }
@@ -0,0 +1,118 @@
1
+ import type {
2
+ AxiosInstance,
3
+ InternalAxiosRequestConfig,
4
+ AxiosResponse,
5
+ } from "axios";
6
+ import { message as antdMessage } from "antd";
7
+ import type { TokenManager, RequestConfig, ApiResponse } from "./types";
8
+ import type { ErrorHandler } from "./error-handler";
9
+
10
+ /**
11
+ * 设置请求拦截器
12
+ */
13
+ export function setupRequestInterceptor(
14
+ instance: AxiosInstance,
15
+ tokenManager: TokenManager
16
+ ): void {
17
+ instance.interceptors.request.use(
18
+ (config: InternalAxiosRequestConfig) => {
19
+ const requestConfig = config as RequestConfig;
20
+
21
+ // 添加 Token(如果需要认证,默认为 true)
22
+ if (requestConfig.requireAuth !== false) {
23
+ const token = tokenManager.getToken();
24
+ if (token && config.headers) {
25
+ config.headers.Authorization = token;
26
+ }
27
+ }
28
+
29
+ // 添加自定义 Headers
30
+ if (requestConfig.customHeaders && config.headers) {
31
+ Object.entries(requestConfig.customHeaders).forEach(([key, value]) => {
32
+ config.headers[key] = value;
33
+ });
34
+ }
35
+
36
+ return config;
37
+ },
38
+ (error) => {
39
+ return Promise.reject(error);
40
+ }
41
+ );
42
+ }
43
+
44
+ /**
45
+ * 设置响应拦截器
46
+ */
47
+ export function setupResponseInterceptor(
48
+ instance: AxiosInstance,
49
+ tokenManager: TokenManager,
50
+ errorHandler: ErrorHandler,
51
+ onUnauthorized?: () => void
52
+ ): void {
53
+ instance.interceptors.response.use(
54
+ (response: AxiosResponse<ApiResponse>) => {
55
+ const config = response.config as RequestConfig;
56
+ const messageConfig = config.message;
57
+
58
+ const { code, message: msg, data } = response.data;
59
+
60
+ // 业务成功(根据实际后端约定调整)
61
+ if (code === 0 || code === 200) {
62
+ // 显示成功消息
63
+ if (messageConfig?.showSuccess) {
64
+ const successMsg = messageConfig.successMessage || msg || "操作成功";
65
+ antdMessage.success(successMsg);
66
+ }
67
+
68
+ // 直接返回 data,简化调用
69
+ return response.data;
70
+ }
71
+
72
+ // 业务失败
73
+ const errorMsg = messageConfig?.errorMessage || msg || "操作失败";
74
+
75
+ if (messageConfig?.showError !== false) {
76
+ antdMessage.error(errorMsg);
77
+ }
78
+
79
+ return Promise.reject(new Error(errorMsg));
80
+ },
81
+ async (error) => {
82
+ const config = error.config as RequestConfig;
83
+
84
+ // 401 未授权
85
+ if (error.response?.status === 401) {
86
+ tokenManager.clearToken();
87
+
88
+ // 执行自定义的未授权回调
89
+ if (onUnauthorized) {
90
+ onUnauthorized();
91
+ } else {
92
+ // 默认跳转到登录页
93
+ redirectToLogin();
94
+ }
95
+
96
+ return Promise.reject(error);
97
+ }
98
+
99
+ // 其他错误统一处理
100
+ errorHandler.handle(error, config);
101
+
102
+ return Promise.reject(error);
103
+ }
104
+ );
105
+ }
106
+
107
+ /**
108
+ * 重定向到登录页
109
+ */
110
+ function redirectToLogin(): void {
111
+ if (typeof window === "undefined") return;
112
+
113
+ const currentPath = window.location.pathname;
114
+ if (currentPath === "/login") return;
115
+
116
+ const redirectUrl = encodeURIComponent(window.location.href);
117
+ window.location.href = `${window.location.origin}/login?redirect=${redirectUrl}`;
118
+ }
@@ -20,12 +20,12 @@ export default class jwt {
20
20
  }
21
21
 
22
22
  // 获取访问令牌
23
- static getAccessToken(accessTokenKey: string) {
24
- return Cookies.get(accessTokenKey);
23
+ static getAccessToken(accessTokenKey?: string) {
24
+ return Cookies.get(accessTokenKey ?? this.key);
25
25
  }
26
26
 
27
27
  // 清空访问令牌
28
- static clearAccessToken(accessTokenKey: string) {
29
- Cookies.remove(accessTokenKey);
28
+ static clearAccessToken(accessTokenKey?: string) {
29
+ Cookies.remove(accessTokenKey ?? this.key);
30
30
  }
31
31
  }
@@ -0,0 +1,136 @@
1
+ import ThemeProvider from "@/components/ThemeProvider";
2
+ import { CLOUD_THEME_APPEARANCE } from "@/const/theme";
3
+ import { setCookie } from "@/utils/cookie";
4
+
5
+ // import { useGlobalStore } from "@store/global";
6
+ import React, { memo, useEffect, type ReactNode } from "react";
7
+
8
+ import { SYSTEM_PREFIX } from "@/const/system";
9
+ import { GlobalStyle } from "@/styles";
10
+ import { useUserStore } from "@store/user";
11
+ import { createStaticStyles, cx } from "antd-style";
12
+ import HarmonyOS_Sans_Regular from "@public/fonts/HarmonyOS_Sans_Regular.woff2";
13
+ import AntdStaticMethods from "@/components/AntdStaticMethods";
14
+
15
+ const styles = createStaticStyles(({ css, cssVar }) => ({
16
+ app: css`
17
+ position: relative;
18
+
19
+ overscroll-behavior: none;
20
+ display: flex;
21
+ flex-direction: column;
22
+ align-items: center;
23
+
24
+ height: 100%;
25
+ min-height: 100dvh;
26
+ max-height: 100dvh;
27
+
28
+ @media (min-device-width: 576px) {
29
+ overflow: hidden;
30
+ }
31
+ `,
32
+ // scrollbar-width and scrollbar-color are supported from Chrome 121
33
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-color
34
+ scrollbar: css`
35
+ scrollbar-color: ${cssVar.colorFill} transparent;
36
+ scrollbar-width: thin;
37
+
38
+ #lobe-mobile-scroll-container {
39
+ scrollbar-width: none;
40
+
41
+ ::-webkit-scrollbar {
42
+ width: 0;
43
+ height: 0;
44
+ }
45
+ }
46
+ `,
47
+
48
+ // so this is a polyfill for older browsers
49
+ scrollbarPolyfill: css`
50
+ ::-webkit-scrollbar {
51
+ width: 0.75em;
52
+ height: 0.75em;
53
+ }
54
+
55
+ ::-webkit-scrollbar-thumb {
56
+ border-radius: 10px;
57
+ }
58
+
59
+ :hover::-webkit-scrollbar-thumb {
60
+ border: 3px solid transparent;
61
+ background-color: ${cssVar.colorText};
62
+ background-clip: content-box;
63
+ }
64
+
65
+ ::-webkit-scrollbar-track {
66
+ background-color: transparent;
67
+ }
68
+ `,
69
+ }));
70
+
71
+ interface AppThemeProps {
72
+ children: ReactNode;
73
+ }
74
+
75
+ const AppTheme = memo(({ children }: AppThemeProps) => {
76
+ const themeMode = useUserStore((s) => s.themeMode);
77
+ const animationMode = useUserStore((s) => s.animationMode);
78
+ const neutralColor = useUserStore((s) => s.neutralColor);
79
+ const primaryColor = useUserStore((s) => s.primaryColor);
80
+
81
+ useEffect(() => {
82
+ // Update data-theme accordingly if user selects light or dark
83
+ if (themeMode !== "auto") {
84
+ document.documentElement.dataset.theme = themeMode;
85
+ return;
86
+ }
87
+
88
+ // For auto mode, we need to watch system preferences
89
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
90
+
91
+ // Set initial theme based on system preference
92
+ document.documentElement.dataset.theme = mediaQuery.matches
93
+ ? "dark"
94
+ : "light";
95
+
96
+ // Update theme when system preference changes
97
+ function handleChange(e) {
98
+ document.documentElement.dataset.theme = e.matches ? "dark" : "light";
99
+ }
100
+
101
+ mediaQuery.addEventListener("change", handleChange);
102
+ return () => mediaQuery.removeEventListener("change", handleChange);
103
+ }, [themeMode]);
104
+
105
+ return (
106
+ <ThemeProvider
107
+ prefixCls={SYSTEM_PREFIX}
108
+ appearance={themeMode !== "auto" ? themeMode : undefined}
109
+ className={cx(styles.app, styles.scrollbar, styles.scrollbarPolyfill)}
110
+ customTheme={{
111
+ neutralColor: neutralColor,
112
+ primaryColor: primaryColor,
113
+ }}
114
+ customFonts={[HarmonyOS_Sans_Regular]}
115
+ theme={{
116
+ cssVar: true,
117
+ token: {
118
+ motion: animationMode !== "disabled",
119
+ motionUnit: animationMode === "agile" ? 0.05 : 0.1,
120
+ },
121
+ }}
122
+ themeMode={themeMode}
123
+ onAppearanceChange={(appearance) => {
124
+ if (themeMode !== "auto") return;
125
+
126
+ setCookie(CLOUD_THEME_APPEARANCE, appearance);
127
+ }}
128
+ >
129
+ {children}
130
+ <AntdStaticMethods />
131
+ <GlobalStyle />
132
+ </ThemeProvider>
133
+ );
134
+ });
135
+
136
+ export default AppTheme;