@qlover/create-app 0.4.5 → 0.4.6

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 (161) hide show
  1. package/CHANGELOG.md +80 -35
  2. package/dist/index.cjs +11 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +10 -2418
  5. package/{templates → dist/templates}/node-lib/package.json +2 -2
  6. package/{templates → dist/templates}/react-app/README.md +6 -6
  7. package/{templates → dist/templates}/react-app/config/Identifier/Error.ts +8 -8
  8. package/dist/templates/react-app/config/Identifier/common.ts +62 -0
  9. package/dist/templates/react-app/config/Identifier/index.ts +10 -0
  10. package/dist/templates/react-app/config/Identifier/page.about.ts +181 -0
  11. package/dist/templates/react-app/config/Identifier/page.executor.ts +267 -0
  12. package/dist/templates/react-app/config/Identifier/page.home.ts +63 -0
  13. package/dist/templates/react-app/config/Identifier/page.identifiter.ts +39 -0
  14. package/dist/templates/react-app/config/Identifier/page.jsonStorage.ts +70 -0
  15. package/dist/templates/react-app/config/Identifier/page.login.ts +152 -0
  16. package/dist/templates/react-app/config/Identifier/page.register.ts +147 -0
  17. package/dist/templates/react-app/config/Identifier/page.request.ts +179 -0
  18. package/dist/templates/react-app/config/app.router.ts +163 -0
  19. package/dist/templates/react-app/config/theme.ts +11 -0
  20. package/{templates → dist/templates}/react-app/package.json +2 -2
  21. package/{templates → dist/templates}/react-app/public/locales/en/common.json +97 -116
  22. package/{templates → dist/templates}/react-app/public/locales/zh/common.json +98 -117
  23. package/{templates → dist/templates}/react-app/src/App.tsx +6 -5
  24. package/dist/templates/react-app/src/base/cases/I18nKeyErrorPlugin.ts +36 -0
  25. package/{templates → dist/templates}/react-app/src/base/cases/RouterLoader.ts +2 -1
  26. package/{templates → dist/templates}/react-app/src/base/services/I18nService.ts +4 -4
  27. package/{templates/react-app/src/base/services/ProcesserService.ts → dist/templates/react-app/src/base/services/ProcesserExecutor.ts} +15 -5
  28. package/{templates → dist/templates}/react-app/src/base/services/RouteService.ts +11 -13
  29. package/{templates → dist/templates}/react-app/src/base/services/UserService.ts +37 -21
  30. package/{templates → dist/templates}/react-app/src/base/types/Page.ts +12 -2
  31. package/{templates → dist/templates}/react-app/src/core/bootstrap.ts +1 -1
  32. package/{templates → dist/templates}/react-app/src/core/bootstraps/index.ts +3 -1
  33. package/{templates → dist/templates}/react-app/src/core/registers/RegisterCommon.ts +7 -7
  34. package/{templates → dist/templates}/react-app/src/core/registers/RegisterControllers.ts +7 -2
  35. package/{templates → dist/templates}/react-app/src/pages/404.tsx +4 -1
  36. package/{templates → dist/templates}/react-app/src/pages/500.tsx +2 -1
  37. package/{templates → dist/templates}/react-app/src/pages/auth/Layout.tsx +1 -1
  38. package/{templates/react-app/src/pages/auth/Login.tsx → dist/templates/react-app/src/pages/auth/LoginPage.tsx} +2 -2
  39. package/{templates/react-app/src/pages/auth/Register.tsx → dist/templates/react-app/src/pages/auth/RegisterPage.tsx} +3 -4
  40. package/{templates/react-app/src/pages/base/About.tsx → dist/templates/react-app/src/pages/base/AboutPage.tsx} +4 -4
  41. package/{templates/react-app/src/pages/base/ErrorIdentifier.tsx → dist/templates/react-app/src/pages/base/ErrorIdentifierPage.tsx} +3 -3
  42. package/{templates/react-app/src/pages/base/Executor.tsx → dist/templates/react-app/src/pages/base/ExecutorPage.tsx} +3 -3
  43. package/{templates/react-app/src/pages/base/Home.tsx → dist/templates/react-app/src/pages/base/HomePage.tsx} +15 -45
  44. package/{templates/react-app/src/pages/base/JSONStorage.tsx → dist/templates/react-app/src/pages/base/JSONStoragePage.tsx} +2 -2
  45. package/{templates → dist/templates}/react-app/src/pages/base/Layout.tsx +4 -4
  46. package/{templates/react-app/src/pages/base/Request.tsx → dist/templates/react-app/src/pages/base/RequestPage.tsx} +2 -2
  47. package/{templates/react-app/src/pages/base → dist/templates/react-app/src/uikit}/components/LogoutButton.tsx +1 -1
  48. package/{templates → dist/templates}/react-app/src/uikit/components/ThemeSwitcher.tsx +5 -6
  49. package/{templates → dist/templates}/react-app/src/uikit/contexts/BaseRouteContext.ts +1 -1
  50. package/{templates → dist/templates}/react-app/src/uikit/controllers/ExecutorController.ts +2 -2
  51. package/{templates → dist/templates}/react-app/src/uikit/controllers/JSONStorageController.ts +2 -2
  52. package/{templates → dist/templates}/react-app/src/uikit/controllers/RequestController.ts +1 -1
  53. package/{templates/react-app/src/uikit/hooks/useLanguageGuard.ts → dist/templates/react-app/src/uikit/hooks/useI18nGuard.ts} +1 -1
  54. package/{templates → dist/templates}/react-app/src/uikit/hooks/useStore.ts +2 -2
  55. package/dist/templates/react-app/src/uikit/hooks/userRouterService.ts +12 -0
  56. package/{templates → dist/templates}/react-app/src/uikit/providers/BaseRouteProvider.tsx +1 -0
  57. package/dist/templates/react-app/src/uikit/providers/ProcessExecutorProvider.tsx +24 -0
  58. package/dist/templates/react-app/src/uikit/providers/UserAuthProvider.tsx +16 -0
  59. package/{templates → dist/templates}/react-app/vite.config.ts +2 -1
  60. package/package.json +4 -6
  61. package/templates/react-app/config/Identifier/Auth.ts +0 -13
  62. package/templates/react-app/config/Identifier/I18n.ts +0 -1366
  63. package/templates/react-app/config/app.router.json +0 -159
  64. package/templates/react-app/config/theme.json +0 -9
  65. package/templates/react-app/src/base/port/LoginInterface.ts +0 -12
  66. package/templates/react-app/src/base/port/StoreInterface.ts +0 -58
  67. package/templates/react-app/src/uikit/providers/ProcessProvider.tsx +0 -45
  68. /package/{configs → dist/configs}/_common/.editorconfig +0 -0
  69. /package/{configs → dist/configs}/_common/.env.template +0 -0
  70. /package/{configs → dist/configs}/_common/.gitattributes +0 -0
  71. /package/{configs → dist/configs}/_common/.github/workflows/general-check.yml +0 -0
  72. /package/{configs → dist/configs}/_common/.github/workflows/release.yml +0 -0
  73. /package/{configs → dist/configs}/_common/.gitignore.template +0 -0
  74. /package/{configs → dist/configs}/_common/.husky/commit-msg +0 -0
  75. /package/{configs → dist/configs}/_common/.husky/pre-commit +0 -0
  76. /package/{configs → dist/configs}/_common/.prettierignore +0 -0
  77. /package/{configs → dist/configs}/_common/.prettierrc.js +0 -0
  78. /package/{configs → dist/configs}/_common/.vscode/extensions.json +0 -0
  79. /package/{configs → dist/configs}/_common/.vscode/react.code-snippets +0 -0
  80. /package/{configs → dist/configs}/_common/.vscode/settings.json +0 -0
  81. /package/{configs → dist/configs}/_common/commitlint.config.js +0 -0
  82. /package/{configs → dist/configs}/_common/package.json.template +0 -0
  83. /package/{configs → dist/configs}/node-lib/eslint.config.js +0 -0
  84. /package/{configs → dist/configs}/react-app/eslint.config.js +0 -0
  85. /package/{templates → dist/templates}/node-lib/__tests__/readJson.test.ts +0 -0
  86. /package/{templates → dist/templates}/node-lib/bin/test.js +0 -0
  87. /package/{templates → dist/templates}/node-lib/rollup.config.js +0 -0
  88. /package/{templates → dist/templates}/node-lib/src/index.ts +0 -0
  89. /package/{templates → dist/templates}/node-lib/src/readJson.ts +0 -0
  90. /package/{templates → dist/templates}/node-lib/tsconfig.json +0 -0
  91. /package/{templates → dist/templates}/pack-app/README.md +0 -0
  92. /package/{templates → dist/templates}/pack-app/eslint.config.js +0 -0
  93. /package/{templates → dist/templates}/pack-app/fe-config.json +0 -0
  94. /package/{templates → dist/templates}/pack-app/package.json +0 -0
  95. /package/{templates → dist/templates}/pack-app/pnpm-workspace.yaml +0 -0
  96. /package/{templates → dist/templates}/pack-app/tsconfig.json +0 -0
  97. /package/{templates → dist/templates}/pack-app/tsconfig.test.json +0 -0
  98. /package/{templates → dist/templates}/pack-app/vite.config.ts +0 -0
  99. /package/{templates → dist/templates}/react-app/.env.template +0 -0
  100. /package/{templates → dist/templates}/react-app/config/common.ts +0 -0
  101. /package/{templates → dist/templates}/react-app/config/feapi.mock.json +0 -0
  102. /package/{templates → dist/templates}/react-app/config/i18n.ts +0 -0
  103. /package/{templates → dist/templates}/react-app/index.html +0 -0
  104. /package/{templates → dist/templates}/react-app/postcss.config.js +0 -0
  105. /package/{templates → dist/templates}/react-app/public/logo.svg +0 -0
  106. /package/{templates → dist/templates}/react-app/public/router-root/logo.svg +0 -0
  107. /package/{templates → dist/templates}/react-app/src/assets/react.svg +0 -0
  108. /package/{templates → dist/templates}/react-app/src/base/apis/AiApi.ts +0 -0
  109. /package/{templates → dist/templates}/react-app/src/base/apis/feApi/FeApi.ts +0 -0
  110. /package/{templates → dist/templates}/react-app/src/base/apis/feApi/FeApiAdapter.ts +0 -0
  111. /package/{templates → dist/templates}/react-app/src/base/apis/feApi/FeApiBootstarp.ts +0 -0
  112. /package/{templates → dist/templates}/react-app/src/base/apis/feApi/FeApiType.ts +0 -0
  113. /package/{templates → dist/templates}/react-app/src/base/apis/userApi/UserApi.ts +0 -0
  114. /package/{templates → dist/templates}/react-app/src/base/apis/userApi/UserApiAdapter.ts +0 -0
  115. /package/{templates → dist/templates}/react-app/src/base/apis/userApi/UserApiBootstarp.ts +0 -0
  116. /package/{templates → dist/templates}/react-app/src/base/apis/userApi/UserApiType.ts +0 -0
  117. /package/{templates → dist/templates}/react-app/src/base/cases/AppConfig.ts +0 -0
  118. /package/{templates → dist/templates}/react-app/src/base/cases/AppError.ts +0 -0
  119. /package/{templates → dist/templates}/react-app/src/base/cases/DialogHandler.ts +0 -0
  120. /package/{templates → dist/templates}/react-app/src/base/cases/PublicAssetsPath.ts +0 -0
  121. /package/{templates → dist/templates}/react-app/src/base/cases/RequestLogger.ts +0 -0
  122. /package/{templates → dist/templates}/react-app/src/base/cases/RequestStatusCatcher.ts +0 -0
  123. /package/{templates → dist/templates}/react-app/src/base/port/ApiTransactionInterface.ts +0 -0
  124. /package/{templates → dist/templates}/react-app/src/base/port/InteractionHubInterface.ts +0 -0
  125. /package/{templates → dist/templates}/react-app/src/base/port/RequestCatcherInterface.ts +0 -0
  126. /package/{templates → dist/templates}/react-app/src/base/port/UIDependenciesInterface.ts +0 -0
  127. /package/{templates → dist/templates}/react-app/src/base/types/deprecated-antd.d.ts +0 -0
  128. /package/{templates → dist/templates}/react-app/src/base/types/global.d.ts +0 -0
  129. /package/{templates → dist/templates}/react-app/src/core/IOC.ts +0 -0
  130. /package/{templates → dist/templates}/react-app/src/core/bootstraps/BootstrapApp.ts +0 -0
  131. /package/{templates → dist/templates}/react-app/src/core/bootstraps/PrintBootstrap.ts +0 -0
  132. /package/{templates → dist/templates}/react-app/src/core/globals.ts +0 -0
  133. /package/{templates → dist/templates}/react-app/src/core/registers/RegisterApi.ts +0 -0
  134. /package/{templates → dist/templates}/react-app/src/core/registers/RegisterGlobals.ts +0 -0
  135. /package/{templates → dist/templates}/react-app/src/core/registers/index.ts +0 -0
  136. /package/{templates → dist/templates}/react-app/src/main.tsx +0 -0
  137. /package/{templates → dist/templates}/react-app/src/pages/base/RedirectPathname.tsx +0 -0
  138. /package/{templates → dist/templates}/react-app/src/styles/css/antd-themes/_default.css +0 -0
  139. /package/{templates → dist/templates}/react-app/src/styles/css/antd-themes/dark.css +0 -0
  140. /package/{templates → dist/templates}/react-app/src/styles/css/antd-themes/index.css +0 -0
  141. /package/{templates → dist/templates}/react-app/src/styles/css/antd-themes/no-context.css +0 -0
  142. /package/{templates → dist/templates}/react-app/src/styles/css/antd-themes/pink.css +0 -0
  143. /package/{templates → dist/templates}/react-app/src/styles/css/index.css +0 -0
  144. /package/{templates → dist/templates}/react-app/src/styles/css/page.css +0 -0
  145. /package/{templates → dist/templates}/react-app/src/styles/css/tailwind.css +0 -0
  146. /package/{templates → dist/templates}/react-app/src/styles/css/themes/_default.css +0 -0
  147. /package/{templates → dist/templates}/react-app/src/styles/css/themes/dark.css +0 -0
  148. /package/{templates → dist/templates}/react-app/src/styles/css/themes/index.css +0 -0
  149. /package/{templates → dist/templates}/react-app/src/styles/css/themes/pink.css +0 -0
  150. /package/{templates/react-app/src/pages/base → dist/templates/react-app/src/uikit}/components/BaseHeader.tsx +0 -0
  151. /package/{templates → dist/templates}/react-app/src/uikit/components/LanguageSwitcher.tsx +0 -0
  152. /package/{templates → dist/templates}/react-app/src/uikit/components/Loading.tsx +0 -0
  153. /package/{templates → dist/templates}/react-app/src/uikit/components/LocaleLink.tsx +0 -0
  154. /package/{templates → dist/templates}/react-app/src/uikit/components/RouterRenderComponent.tsx +0 -0
  155. /package/{templates → dist/templates}/react-app/src/uikit/hooks/useDocumentTitle.ts +0 -0
  156. /package/{templates → dist/templates}/react-app/src/uikit/hooks/useStrictEffect.ts +0 -0
  157. /package/{templates → dist/templates}/react-app/src/vite-env.d.ts +0 -0
  158. /package/{templates → dist/templates}/react-app/tailwind.config.js +0 -0
  159. /package/{templates → dist/templates}/react-app/tsconfig.app.json +0 -0
  160. /package/{templates → dist/templates}/react-app/tsconfig.json +0 -0
  161. /package/{templates → dist/templates}/react-app/tsconfig.node.json +0 -0
@@ -4,11 +4,11 @@ import LanguageDetector from 'i18next-browser-languagedetector';
4
4
  import HttpApi from 'i18next-http-backend';
5
5
  import merge from 'lodash/merge';
6
6
  import i18nConfig from '@config/i18n';
7
- import type { BootstrapExecutorPlugin } from '@qlover/corekit-bridge';
8
7
  import {
9
- StoreInterface,
10
- StoreStateInterface
11
- } from '@/base/port/StoreInterface';
8
+ type BootstrapExecutorPlugin,
9
+ type StoreStateInterface,
10
+ StoreInterface
11
+ } from '@qlover/corekit-bridge';
12
12
  const { supportedLngs, fallbackLng } = i18nConfig;
13
13
 
14
14
  export type I18nServiceLocale = (typeof supportedLngs)[number];
@@ -2,12 +2,15 @@ import { AsyncExecutor, ExecutorPlugin } from '@qlover/fe-corekit';
2
2
  import { IOCIdentifier } from '@/core/IOC';
3
3
  import { injectable, inject } from 'inversify';
4
4
  import type { LoggerInterface } from '@qlover/logger';
5
+ import { RouteService } from './RouteService';
5
6
 
6
7
  @injectable()
7
- export class ProcesserService {
8
+ export class ProcesserExecutor {
9
+ protected executor: AsyncExecutor = new AsyncExecutor();
10
+
8
11
  constructor(
9
12
  @inject(IOCIdentifier.Logger) private logger: LoggerInterface,
10
- @inject(AsyncExecutor) private executor: AsyncExecutor
13
+ @inject(RouteService) private routeService: RouteService
11
14
  ) {}
12
15
 
13
16
  use(plugin: ExecutorPlugin): this {
@@ -21,9 +24,16 @@ export class ProcesserService {
21
24
  });
22
25
  }
23
26
 
24
- init(): Promise<unknown> {
25
- return this.executor.exec(this.handler).catch((err) => {
27
+ async starup(): Promise<unknown> {
28
+ this.logger.info('PageProcesser startup');
29
+
30
+ try {
31
+ const result = await this.executor.exec(this.handler);
32
+ return result;
33
+ } catch (err) {
26
34
  this.logger.error('PageProcesser init failed', err);
27
- });
35
+
36
+ this.routeService.gotoLogin();
37
+ }
28
38
  }
29
39
  }
@@ -3,23 +3,23 @@ import type { NavigateFunction, NavigateOptions } from 'react-router-dom';
3
3
  import type { UIDependenciesInterface } from '@/base/port/UIDependenciesInterface';
4
4
  import type { LoggerInterface } from '@qlover/logger';
5
5
  import { I18nService } from '@/base/services/I18nService';
6
+ import { StoreInterface, StoreStateInterface } from '@qlover/corekit-bridge';
6
7
 
7
8
  export type RouterServiceDependencies = {
8
9
  navigate: NavigateFunction;
9
10
  };
10
11
 
11
12
  export type RouterServiceOptions = {
12
- config: {
13
- routes: RouteConfigValue[];
14
- };
13
+ routes: RouteConfigValue[];
15
14
  logger: LoggerInterface;
16
15
  };
17
16
 
18
- export type RouterServiceState = {
19
- routes: RouteConfigValue[];
20
- };
17
+ export class RouterServiceState implements StoreStateInterface {
18
+ constructor(public routes: RouteConfigValue[] = []) {}
19
+ }
21
20
 
22
21
  export class RouteService
22
+ extends StoreInterface<RouterServiceState>
23
23
  implements UIDependenciesInterface<RouterServiceDependencies>
24
24
  {
25
25
  /**
@@ -27,12 +27,8 @@ export class RouteService
27
27
  */
28
28
  dependencies?: RouterServiceDependencies;
29
29
 
30
- state: RouterServiceState;
31
-
32
30
  constructor(private options: RouterServiceOptions) {
33
- this.state = {
34
- routes: options.config.routes
35
- };
31
+ super(() => new RouterServiceState(options.routes));
36
32
  }
37
33
 
38
34
  get logger(): LoggerInterface {
@@ -43,7 +39,9 @@ export class RouteService
43
39
  const navigate = this.dependencies?.navigate;
44
40
 
45
41
  if (!navigate) {
46
- this.logger.debug('navigate is not set');
42
+ this.logger.debug(
43
+ 'Please use `RouterServiceProvider` to set dependencies'
44
+ );
47
45
  }
48
46
 
49
47
  return navigate;
@@ -69,7 +67,7 @@ export class RouteService
69
67
  }
70
68
 
71
69
  changeRoutes(routes: RouteConfigValue[]): void {
72
- this.state.routes = routes;
70
+ this.emit({ routes });
73
71
  }
74
72
 
75
73
  goto(path: string, options?: NavigateOptions): void {
@@ -1,21 +1,34 @@
1
- import { ExecutorPlugin } from '@qlover/fe-corekit';
1
+ import type { ExecutorPlugin } from '@qlover/fe-corekit';
2
2
  import type {
3
3
  UserApiGetUserInfoTransaction,
4
4
  UserApiLoginTransaction
5
5
  } from '@/base/apis/userApi/UserApiType';
6
6
  import { RouteService } from './RouteService';
7
- import { ThreadUtil, type StorageTokenInterface } from '@qlover/corekit-bridge';
7
+ import {
8
+ StoreInterface,
9
+ StoreStateInterface,
10
+ type StorageTokenInterface
11
+ } from '@qlover/corekit-bridge';
8
12
  import { inject, injectable } from 'inversify';
9
13
  import { IOCIdentifier } from '@/core/IOC';
10
- import { LoginInterface, RegisterFormData } from '@/base/port/LoginInterface';
11
14
  import { UserApi } from '@/base/apis/userApi/UserApi';
12
15
  import { AppError } from '@/base/cases/AppError';
13
- import { StoreInterface, StoreStateInterface } from '../port/StoreInterface';
14
- import * as errKeys from '@config/Identifier/Error';
16
+ import * as errKeys from '@config/Identifier/error';
17
+
18
+ export type UserServiceUserInfo =
19
+ UserApiGetUserInfoTransaction['response']['data'];
20
+
21
+ export interface RegisterFormData {
22
+ username: string;
23
+ email: string;
24
+ password: string;
25
+ confirmPassword: string;
26
+ agreeToTerms: boolean;
27
+ }
15
28
 
16
29
  class UserServiceState implements StoreStateInterface {
17
30
  success: boolean = false;
18
- userInfo: UserApiGetUserInfoTransaction['response']['data'] = {
31
+ userInfo: UserServiceUserInfo = {
19
32
  name: '',
20
33
  email: '',
21
34
  picture: ''
@@ -25,28 +38,30 @@ class UserServiceState implements StoreStateInterface {
25
38
  @injectable()
26
39
  export class UserService
27
40
  extends StoreInterface<UserServiceState>
28
- implements ExecutorPlugin, LoginInterface
41
+ implements ExecutorPlugin
29
42
  {
30
43
  readonly pluginName = 'UserService';
31
44
 
32
45
  constructor(
33
46
  @inject(UserApi) private userApi: UserApi,
34
- @inject(RouteService) private routerController: RouteService,
47
+ @inject(RouteService) private routerService: RouteService,
35
48
  @inject(IOCIdentifier.FeApiToken)
36
49
  private userToken: StorageTokenInterface<string>
37
50
  ) {
38
51
  super(() => new UserServiceState());
39
52
  }
40
53
 
41
- setState(state: Partial<UserServiceState>): void {
42
- this.emit({ ...this.state, ...state });
43
- }
54
+ selector = {
55
+ success: (state: UserServiceState) => state.success
56
+ };
44
57
 
45
58
  /**
46
59
  * @override
47
60
  */
48
61
  async onBefore(): Promise<void> {
49
- await ThreadUtil.sleep(1000);
62
+ if (this.isAuthenticated()) {
63
+ return;
64
+ }
50
65
 
51
66
  const userToken = this.userToken.getToken();
52
67
 
@@ -56,19 +71,18 @@ export class UserService
56
71
 
57
72
  const userInfo = await this.userApi.getUserInfo();
58
73
 
59
- this.setState({
74
+ this.emit({
60
75
  success: true,
61
76
  userInfo: userInfo.data
62
77
  });
63
78
  }
64
79
 
65
- /**
66
- * @override
67
- */
68
- async onError(): Promise<void> {
69
- this.logout();
70
-
71
- this.routerController.gotoLogin();
80
+ onSuccess(): void | Promise<void> {
81
+ if (this.isAuthenticated()) {
82
+ this.emit({ ...this.state, success: true });
83
+ } else {
84
+ this.logout();
85
+ }
72
86
  }
73
87
 
74
88
  /**
@@ -91,7 +105,7 @@ export class UserService
91
105
 
92
106
  const userInfo = await this.userApi.getUserInfo();
93
107
 
94
- this.setState({
108
+ this.emit({
95
109
  success: true,
96
110
  userInfo: userInfo.data
97
111
  });
@@ -104,6 +118,8 @@ export class UserService
104
118
  */
105
119
  logout(): void {
106
120
  this.reset();
121
+ this.routerService.reset();
122
+ this.routerService.gotoLogin();
107
123
  }
108
124
 
109
125
  /**
@@ -10,12 +10,22 @@ export interface BasePageProvider {
10
10
  type RouteCategory = 'main' | 'auth' | 'common';
11
11
 
12
12
  export interface RouteMeta {
13
- category?: RouteCategory;
14
13
  /**
15
- * from app.router.json
14
+ * The title of the route
16
15
  */
17
16
  title?: string;
17
+
18
+ /**
19
+ * The description of the route
20
+ */
21
+ description?: string;
22
+
23
+ /**
24
+ * The icon of the route
25
+ */
18
26
  icon?: string;
27
+
28
+ category?: RouteCategory;
19
29
  /**
20
30
  * from app.router.json
21
31
  *
@@ -4,7 +4,7 @@ import { IOC } from './IOC';
4
4
  import * as globals from '@/core/globals';
5
5
  import { IocRegister } from './registers';
6
6
  import { BootstrapsRegistry } from './bootstraps';
7
- import { GLOBAL_NO_WINDOW } from '@config/Identifier/Error';
7
+ import { GLOBAL_NO_WINDOW } from '@config/Identifier/error';
8
8
 
9
9
  export default async function startup({
10
10
  root,
@@ -11,6 +11,7 @@ import { AiApiBootstarp } from '@/base/apis/AiApi';
11
11
  import { printBootstrap } from './PrintBootstrap';
12
12
  import { IOCIdentifier, type IOCIdentifierMap } from '../IOC';
13
13
  import { I18nService } from '@/base/services/I18nService';
14
+ import { I18nKeyErrorPlugin } from '@/base/cases/I18nKeyErrorPlugin';
14
15
 
15
16
  export class BootstrapsRegistry {
16
17
  constructor(
@@ -29,7 +30,8 @@ export class BootstrapsRegistry {
29
30
  new UserApiBootstarp(),
30
31
  new FeApiBootstarp(),
31
32
  AiApiBootstarp,
32
- new BootstrapApp()
33
+ new BootstrapApp(),
34
+ IOC(I18nKeyErrorPlugin)
33
35
  ];
34
36
 
35
37
  if (this.appConfig.env !== 'production') {
@@ -16,11 +16,11 @@ import {
16
16
  } from '@qlover/corekit-bridge';
17
17
  import mockDataJson from '@config/feapi.mock.json';
18
18
  import { RequestStatusCatcher } from '@/base/cases/RequestStatusCatcher';
19
- import themeConfig from '@config/theme.json';
19
+ import { themeConfig } from '@config/theme';
20
20
  import { localJsonStorage, logger } from '../globals';
21
21
  import { I18nService } from '@/base/services/I18nService';
22
22
  import { RouteService } from '@/base/services/RouteService';
23
- import { base as baseRoutes } from '@config/app.router.json';
23
+ import { baseRoutes } from '@config/app.router';
24
24
 
25
25
  export class RegisterCommon implements InversifyRegisterInterface {
26
26
  register(
@@ -30,10 +30,10 @@ export class RegisterCommon implements InversifyRegisterInterface {
30
30
  ): void {
31
31
  const AppConfig = container.get(IOCIdentifier.AppConfig);
32
32
 
33
- const userToken = new UserToken(
34
- AppConfig.userTokenStorageKey,
35
- container.get(JSONStorage)
36
- );
33
+ const userToken = new UserToken({
34
+ storageKey: AppConfig.userTokenStorageKey,
35
+ storage: container.get(JSONStorage)
36
+ });
37
37
  const feApiAbort = new FetchAbortPlugin();
38
38
  const feApiRequestCommonPlugin = new RequestCommonPlugin({
39
39
  tokenPrefix: AppConfig.openAiTokenPrefix,
@@ -69,7 +69,7 @@ export class RegisterCommon implements InversifyRegisterInterface {
69
69
  container.bind(
70
70
  RouteService,
71
71
  new RouteService({
72
- config: baseRoutes,
72
+ routes: baseRoutes,
73
73
  logger
74
74
  })
75
75
  );
@@ -1,15 +1,20 @@
1
1
  import { localJsonStorage } from '../globals';
2
2
  import { JSONStorageController } from '@/uikit/controllers/JSONStorageController';
3
- import { ProcesserService } from '@/base/services/ProcesserService';
3
+ import { ProcesserExecutor } from '@/base/services/ProcesserExecutor';
4
4
  import { UserService } from '@/base/services/UserService';
5
5
  import { InversifyRegisterInterface } from '../IOC';
6
6
  import { InversifyContainer } from '../IOC';
7
+ import { I18nKeyErrorPlugin } from '@/base/cases/I18nKeyErrorPlugin';
8
+
7
9
  export class RegisterControllers implements InversifyRegisterInterface {
8
10
  register(container: InversifyContainer): void {
9
11
  const jsonStorageController = new JSONStorageController(localJsonStorage);
10
12
 
11
13
  container.bind(JSONStorageController, jsonStorageController);
12
14
 
13
- container.get(ProcesserService).use(container.get(UserService));
15
+ container
16
+ .get(ProcesserExecutor)
17
+ .use(container.get(I18nKeyErrorPlugin))
18
+ .use(container.get(UserService));
14
19
  }
15
20
  }
@@ -1,4 +1,6 @@
1
1
  import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
2
+ import { PAGE_404_TITLE } from '@config/Identifier/common';
3
+ import { NOT_FOUND_COMPONENT } from '@config/Identifier/error';
2
4
 
3
5
  export default function NotFound({ route }: { route?: string }) {
4
6
  const { t } = useBaseRoutePage();
@@ -6,7 +8,8 @@ export default function NotFound({ route }: { route?: string }) {
6
8
  <div className="flex flex-col justify-center min-h-screen py-6 bg-background sm:py-12">
7
9
  <div className="relative py-3 mx-auto sm:max-w-xl">
8
10
  <h1 className="text-text text-2xl font-bold text-center">
9
- 404 -{route ? `${t('404.notComponent')}: ${route}` : t('404.notPage')}
11
+ 404 -
12
+ {route ? `${t(NOT_FOUND_COMPONENT)}: ${route}` : t(PAGE_404_TITLE)}
10
13
  </h1>
11
14
  </div>
12
15
  </div>
@@ -1,4 +1,5 @@
1
1
  import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
2
+ import { PAGE_500_TITLE } from '@config/Identifier/common';
2
3
 
3
4
  export default function NotFound500() {
4
5
  const { t } = useBaseRoutePage();
@@ -6,7 +7,7 @@ export default function NotFound500() {
6
7
  <div className="flex flex-col justify-center min-h-screen py-6 bg-background sm:py-12">
7
8
  <div className="relative py-3 mx-auto sm:max-w-xl">
8
9
  <h1 className="text-text text-2xl font-bold text-center">
9
- 500 - {t('500.title')}
10
+ 500 - {t(PAGE_500_TITLE)}
10
11
  </h1>
11
12
  </div>
12
13
  </div>
@@ -2,7 +2,7 @@ import { IOC } from '@/core/IOC';
2
2
  import { UserService } from '@/base/services/UserService';
3
3
  import { Navigate, Outlet } from 'react-router-dom';
4
4
  import { useStore } from '@/uikit/hooks/useStore';
5
- import BaseHeader from '../base/components/BaseHeader';
5
+ import BaseHeader from '../../uikit/components/BaseHeader';
6
6
 
7
7
  export default function Layout() {
8
8
  const userService = IOC(UserService);
@@ -6,7 +6,7 @@ import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
6
6
  import { RouteService } from '@/base/services/RouteService';
7
7
  import { UserService } from '@/base/services/UserService';
8
8
  import { useStore } from '@/uikit/hooks/useStore';
9
- import * as i18nKeys from '@config/Identifier/I18n';
9
+ import * as i18nKeys from '@config/Identifier/page.login';
10
10
  import LocaleLink from '@/uikit/components/LocaleLink';
11
11
 
12
12
  interface LoginFormData {
@@ -14,7 +14,7 @@ interface LoginFormData {
14
14
  password: string;
15
15
  }
16
16
 
17
- export default function Login() {
17
+ export default function LoginPage() {
18
18
  const { t } = useBaseRoutePage();
19
19
  const userService = IOC(UserService);
20
20
  const AppConfig = IOC('AppConfig');
@@ -4,12 +4,11 @@ import { UserOutlined, LockOutlined, MailOutlined } from '@ant-design/icons';
4
4
  import { IOC } from '@/core/IOC';
5
5
  import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
6
6
  import { RouteService } from '@/base/services/RouteService';
7
- import { UserService } from '@/base/services/UserService';
7
+ import { RegisterFormData, UserService } from '@/base/services/UserService';
8
8
  import { useStore } from '@/uikit/hooks/useStore';
9
- import * as i18nKeys from '@config/Identifier/I18n';
10
- import type { RegisterFormData } from '@/base/port/LoginInterface';
9
+ import * as i18nKeys from '@config/Identifier/page.register';
11
10
 
12
- export default function Register() {
11
+ export default function RegisterPage() {
13
12
  const { t } = useBaseRoutePage();
14
13
  const userService = IOC(UserService);
15
14
  const AppConfig = IOC('AppConfig');
@@ -1,5 +1,5 @@
1
1
  import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
2
- import * as i18nKeys from '@config/Identifier/I18n';
2
+ import * as i18nKeys from '@config/Identifier/page.about';
3
3
  import {
4
4
  Button,
5
5
  Tooltip,
@@ -13,7 +13,7 @@ import {
13
13
  } from 'antd';
14
14
  import { useState } from 'react';
15
15
 
16
- export default function About() {
16
+ export default function AboutPage() {
17
17
  const { t } = useBaseRoutePage();
18
18
  const [messageApi, contextHolder] = message.useMessage();
19
19
  const [notificationApi, contextHolder2] = notification.useNotification();
@@ -108,8 +108,8 @@ export default function About() {
108
108
  <Popconfirm
109
109
  title={t(i18nKeys.ABOUT_POPCONFIRM_TITLE)}
110
110
  description={t(i18nKeys.ABOUT_POPCONFIRM_DESC)}
111
- okText={t(i18nKeys.COMMON_OK)}
112
- cancelText={t(i18nKeys.COMMON_CANCEL)}
111
+ okText={t(i18nKeys.ABOUT_OK_TEXT)}
112
+ cancelText={t(i18nKeys.ABOUT_CANCEL_TEXT)}
113
113
  >
114
114
  <Button>{t(i18nKeys.ABOUT_BTN_POPCONFIRM)}</Button>
115
115
  </Popconfirm>
@@ -1,9 +1,9 @@
1
1
  import { Button } from 'antd';
2
2
  import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
3
- import * as ErrorIdentifierList from '@config/Identifier/Error';
4
- import * as i18nKeys from '@config/Identifier/I18n';
3
+ import * as ErrorIdentifierList from '@config/Identifier/error';
4
+ import * as i18nKeys from '@config/Identifier/page.identifiter';
5
5
 
6
- export default function ErrorIdentifier() {
6
+ export default function ErrorIdentifierPage() {
7
7
  const { t } = useBaseRoutePage();
8
8
 
9
9
  return (
@@ -5,7 +5,7 @@ import { IOC } from '@/core/IOC';
5
5
  import { JSONStorageController } from '@/uikit/controllers/JSONStorageController';
6
6
  import { ExecutorController } from '@/uikit/controllers/ExecutorController';
7
7
  import { useStore } from '@/uikit/hooks/useStore';
8
- import * as i18nKeys from '@config/Identifier/I18n';
8
+ import * as i18nKeys from '@config/Identifier/page.executor';
9
9
 
10
10
  interface Task {
11
11
  id: string;
@@ -20,7 +20,7 @@ interface Task {
20
20
  method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
21
21
  }
22
22
 
23
- export default function Executor() {
23
+ export default function ExecutorPage() {
24
24
  const { t } = useBaseRoutePage();
25
25
  const executorController = IOC(ExecutorController);
26
26
  const jSONStorageController = IOC(JSONStorageController);
@@ -250,7 +250,7 @@ export default function Executor() {
250
250
  </h2>
251
251
  <div className="space-y-4">
252
252
  <div className="text-text-secondary">
253
- {t(i18nKeys.PAGE_REQUEST_TIMEOUT)}: {requestTimeout}
253
+ {t(i18nKeys.PAGE_EXECUTOR_REQUEST_TIMEOUT)}: {requestTimeout}
254
254
  </div>
255
255
  <div>
256
256
  {helloState.loading ? (
@@ -2,53 +2,23 @@ import { Button } from 'antd';
2
2
  import { useBaseRoutePage } from '@/uikit/contexts/BaseRouteContext';
3
3
  import LocaleLink from '@/uikit/components/LocaleLink';
4
4
  import clsx from 'clsx';
5
- import * as i18nKeys from '@config/Identifier/I18n';
5
+ import * as i18nKeys from '@config/Identifier';
6
+ import { baseRoutes } from '@config/app.router';
6
7
 
7
- export default function Home() {
8
- const { t } = useBaseRoutePage();
8
+ const layoutRoutes = baseRoutes.filter(
9
+ (route) => route.element === 'base/Layout'
10
+ );
11
+
12
+ const navigationItems = layoutRoutes[0]!
13
+ .children!.filter((route) => !route.index)
14
+ .map((route) => ({
15
+ href: `/${route.path}`,
16
+ titleKey: route.meta!.title!,
17
+ descriptionKey: route.meta!.description!
18
+ }));
9
19
 
10
- const navigationItems = [
11
- {
12
- href: '/about',
13
- bgColor: 'bg-blue-50',
14
- hoverColor: 'hover:bg-blue-100',
15
- titleColor: 'text-blue-700',
16
- titleKey: i18nKeys.PAGE_ABOUT_TITLE,
17
- descriptionKey: i18nKeys.PAGE_ABOUT_DESCRIPTION
18
- },
19
- {
20
- href: '/jsonstorage',
21
- bgColor: 'bg-green-50',
22
- hoverColor: 'hover:bg-green-100',
23
- titleColor: 'text-green-700',
24
- titleKey: i18nKeys.PAGE_JSONSTORAGE_TITLE,
25
- descriptionKey: i18nKeys.PAGE_JSONSTORAGE_DESCRIPTION
26
- },
27
- {
28
- href: '/request',
29
- bgColor: 'bg-red-50',
30
- hoverColor: 'hover:bg-red-100',
31
- titleColor: 'text-red-700',
32
- titleKey: i18nKeys.PAGE_REQUEST_TITLE,
33
- descriptionKey: i18nKeys.PAGE_REQUEST_DESCRIPTION
34
- },
35
- {
36
- href: '/executor',
37
- bgColor: 'bg-purple-50',
38
- hoverColor: 'hover:bg-purple-100',
39
- titleColor: 'text-purple-700',
40
- titleKey: i18nKeys.PAGE_EXECUTOR_TITLE,
41
- descriptionKey: i18nKeys.PAGE_EXECUTOR_DESCRIPTION
42
- },
43
- {
44
- href: '/errorIdentifier',
45
- bgColor: 'bg-amber-50',
46
- hoverColor: 'hover:bg-amber-100',
47
- titleColor: 'text-amber-700',
48
- titleKey: i18nKeys.PAGE_ERROR_IDENTIFIER_TITLE,
49
- descriptionKey: i18nKeys.PAGE_ERROR_IDENTIFIER_DESCRIPTION
50
- }
51
- ];
20
+ export default function HomePage() {
21
+ const { t } = useBaseRoutePage();
52
22
 
53
23
  return (
54
24
  <div className="min-h-screen bg-primary">
@@ -4,9 +4,9 @@ import template from 'lodash/template';
4
4
  import { JSONStorageController } from '@/uikit/controllers/JSONStorageController';
5
5
  import { useStore } from '@/uikit/hooks/useStore';
6
6
  import { Button, Input } from 'antd';
7
- import * as i18nKeys from '@config/Identifier/I18n';
7
+ import * as i18nKeys from '@config/Identifier/page.jsonStorage';
8
8
 
9
- export default function JSONStorage() {
9
+ export default function JSONStoragePage() {
10
10
  const jsonStorageController = IOC(JSONStorageController);
11
11
  const controllerState = useStore(jsonStorageController);
12
12
  const { t } = useBaseRoutePage();
@@ -1,10 +1,10 @@
1
- import BaseHeader from './components/BaseHeader';
1
+ import BaseHeader from '../../uikit/components/BaseHeader';
2
2
  import { Outlet } from 'react-router-dom';
3
- import { ProcessProvider } from '@/uikit/providers/ProcessProvider';
3
+ import { ProcessExecutorProvider } from '@/uikit/providers/ProcessExecutorProvider';
4
4
 
5
5
  export default function Layout() {
6
6
  return (
7
- <ProcessProvider>
7
+ <ProcessExecutorProvider>
8
8
  <div
9
9
  data-testid="basic-layout"
10
10
  className="text-base min-h-screen bg-primary"
@@ -15,6 +15,6 @@ export default function Layout() {
15
15
  <Outlet />
16
16
  </div>
17
17
  </div>
18
- </ProcessProvider>
18
+ </ProcessExecutorProvider>
19
19
  );
20
20
  }
@@ -6,7 +6,7 @@ import { useMemo } from 'react';
6
6
  import { useStore } from '@/uikit/hooks/useStore';
7
7
  import { Button } from 'antd';
8
8
  import { LoadingOutlined } from '@ant-design/icons';
9
- import * as i18nKeys from '@config/Identifier/I18n';
9
+ import * as i18nKeys from '@config/Identifier/page.request';
10
10
 
11
11
  function JSONValue({ value }: { value: unknown }) {
12
12
  const output = useMemo(() => {
@@ -23,7 +23,7 @@ function JSONValue({ value }: { value: unknown }) {
23
23
  );
24
24
  }
25
25
 
26
- export default function Request() {
26
+ export default function RequestPage() {
27
27
  const requestController = IOC(RequestController);
28
28
  const requestControllerState = useStore(requestController);
29
29
  const jsonStorageControllerState = useStore(IOC(JSONStorageController));
@@ -3,7 +3,7 @@ import { IOC } from '@/core/IOC';
3
3
  import {
4
4
  AUTH_LOGOUT_DIALOG_CONTENT,
5
5
  AUTH_LOGOUT_DIALOG_TITLE
6
- } from '@config/Identifier/Auth';
6
+ } from '@config/Identifier/common';
7
7
  import { Button } from 'antd';
8
8
  import { useCallback } from 'react';
9
9
  import { useTranslation } from 'react-i18next';