@qlover/create-app 0.10.1 → 0.10.3

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 (214) hide show
  1. package/CHANGELOG.md +178 -0
  2. package/dist/configs/_common/.github/workflows/general-check.yml +1 -1
  3. package/dist/configs/_common/.github/workflows/release.yml +2 -2
  4. package/dist/index.cjs +4 -4
  5. package/dist/index.js +4 -4
  6. package/dist/templates/next-app/config/IOCIdentifier.ts +2 -2
  7. package/dist/templates/next-app/config/Identifier/common/common.ts +14 -0
  8. package/dist/templates/next-app/config/Identifier/pages/index.ts +1 -0
  9. package/dist/templates/next-app/config/Identifier/pages/page.about.ts +20 -0
  10. package/dist/templates/next-app/config/common.ts +1 -1
  11. package/dist/templates/next-app/config/cookies.ts +23 -0
  12. package/dist/templates/next-app/config/i18n/AboutI18n.ts +14 -0
  13. package/dist/templates/next-app/config/i18n/i18nConfig.ts +3 -1
  14. package/dist/templates/next-app/config/i18n/index.ts +1 -0
  15. package/dist/templates/next-app/config/i18n/loginI18n.ts +8 -0
  16. package/dist/templates/next-app/config/theme.ts +4 -0
  17. package/dist/templates/next-app/eslint.config.mjs +9 -2
  18. package/dist/templates/next-app/next.config.ts +1 -0
  19. package/dist/templates/next-app/package.json +17 -6
  20. package/dist/templates/next-app/public/locales/en.json +5 -0
  21. package/dist/templates/next-app/public/locales/zh.json +5 -0
  22. package/dist/templates/next-app/src/app/[locale]/admin/AdminI18nProvider.tsx +37 -0
  23. package/dist/templates/next-app/src/app/[locale]/admin/layout.tsx +30 -6
  24. package/dist/templates/next-app/src/app/[locale]/admin/locales/page.tsx +1 -1
  25. package/dist/templates/next-app/src/app/[locale]/layout.tsx +47 -10
  26. package/dist/templates/next-app/src/app/[locale]/login/LoginForm.tsx +1 -1
  27. package/dist/templates/next-app/src/app/[locale]/login/page.tsx +22 -10
  28. package/dist/templates/next-app/src/app/[locale]/page.tsx +23 -8
  29. package/dist/templates/next-app/src/app/[locale]/register/page.tsx +21 -9
  30. package/dist/templates/next-app/src/app/api/admin/locales/create/route.ts +7 -28
  31. package/dist/templates/next-app/src/app/api/admin/locales/import/route.ts +7 -34
  32. package/dist/templates/next-app/src/app/api/admin/locales/route.ts +12 -34
  33. package/dist/templates/next-app/src/app/api/admin/locales/update/route.ts +7 -26
  34. package/dist/templates/next-app/src/app/api/admin/users/route.ts +14 -33
  35. package/dist/templates/next-app/src/app/api/locales/json/route.ts +13 -25
  36. package/dist/templates/next-app/src/app/api/user/login/route.ts +6 -46
  37. package/dist/templates/next-app/src/app/api/user/logout/route.ts +5 -24
  38. package/dist/templates/next-app/src/app/api/user/register/route.ts +6 -45
  39. package/dist/templates/next-app/src/app/manifest.ts +16 -0
  40. package/dist/templates/next-app/src/app/robots.txt +2 -0
  41. package/dist/templates/next-app/src/base/cases/AdminPageManager.ts +3 -3
  42. package/dist/templates/next-app/src/base/cases/AppConfig.ts +14 -13
  43. package/dist/templates/next-app/src/base/cases/Datetime.ts +3 -3
  44. package/dist/templates/next-app/src/base/cases/DialogErrorPlugin.ts +8 -2
  45. package/dist/templates/next-app/src/base/cases/DialogHandler.ts +30 -4
  46. package/dist/templates/next-app/src/base/cases/InversifyContainer.ts +16 -4
  47. package/dist/templates/next-app/src/base/cases/NavigateBridge.ts +20 -4
  48. package/dist/templates/next-app/src/base/cases/RequestEncryptPlugin.ts +8 -2
  49. package/dist/templates/next-app/src/base/cases/ResourceState.ts +3 -3
  50. package/dist/templates/next-app/src/base/cases/RouterService.ts +28 -10
  51. package/dist/templates/next-app/src/base/cases/StringEncryptor.ts +14 -2
  52. package/dist/templates/next-app/src/base/cases/TranslateI18nInterface.ts +1 -1
  53. package/dist/templates/next-app/src/base/cases/UserServiceApi.ts +20 -5
  54. package/dist/templates/next-app/src/base/cases/ZodColumnBuilder.ts +31 -8
  55. package/dist/templates/next-app/src/base/port/AdminLayoutInterface.ts +4 -1
  56. package/dist/templates/next-app/src/base/port/AppApiInterface.ts +22 -0
  57. package/dist/templates/next-app/src/base/port/I18nServiceInterface.ts +27 -7
  58. package/dist/templates/next-app/src/base/port/IOCInterface.ts +9 -0
  59. package/dist/templates/next-app/src/base/services/AdminPageEvent.ts +1 -1
  60. package/dist/templates/next-app/src/base/services/AdminPageScheduler.ts +3 -3
  61. package/dist/templates/next-app/src/base/services/I18nService.ts +20 -10
  62. package/dist/templates/next-app/src/base/services/ResourceService.ts +32 -11
  63. package/dist/templates/next-app/src/base/services/UserService.ts +12 -3
  64. package/dist/templates/next-app/src/base/services/adminApi/AdminLocalesApi.ts +9 -6
  65. package/dist/templates/next-app/src/base/services/adminApi/AdminUserApi.ts +20 -5
  66. package/dist/templates/next-app/src/base/services/appApi/AppApiPlugin.ts +21 -4
  67. package/dist/templates/next-app/src/base/services/appApi/AppUserApi.ts +12 -3
  68. package/dist/templates/next-app/src/base/services/appApi/AppUserApiBootstrap.ts +10 -2
  69. package/dist/templates/next-app/src/base/types/{PageProps.ts → AppPageRouter.ts} +4 -1
  70. package/dist/templates/next-app/src/base/types/PagesRouter.ts +9 -0
  71. package/dist/templates/next-app/src/core/bootstraps/BootstrapClient.ts +20 -6
  72. package/dist/templates/next-app/src/core/bootstraps/BootstrapServer.ts +27 -9
  73. package/dist/templates/next-app/src/core/bootstraps/BootstrapsRegistry.ts +6 -4
  74. package/dist/templates/next-app/src/core/clientIoc/ClientIOC.ts +39 -9
  75. package/dist/templates/next-app/src/core/clientIoc/ClientIOCRegister.ts +9 -2
  76. package/dist/templates/next-app/src/core/serverIoc/ServerIOC.ts +37 -10
  77. package/dist/templates/next-app/src/core/serverIoc/ServerIOCRegister.ts +9 -2
  78. package/dist/templates/next-app/src/i18n/loadMessages.ts +103 -0
  79. package/dist/templates/next-app/src/i18n/request.ts +3 -22
  80. package/dist/templates/next-app/src/pages/[locale]/about.tsx +61 -0
  81. package/dist/templates/next-app/src/pages/_app.tsx +50 -0
  82. package/dist/templates/next-app/src/pages/_document.tsx +13 -0
  83. package/dist/templates/next-app/src/{middleware.ts → proxy.ts} +2 -1
  84. package/dist/templates/next-app/src/server/AppErrorApi.ts +1 -1
  85. package/dist/templates/next-app/src/server/AppPageRouteParams.ts +107 -0
  86. package/dist/templates/next-app/src/server/AppSuccessApi.ts +1 -1
  87. package/dist/templates/next-app/src/server/NextApiServer.ts +62 -0
  88. package/dist/templates/next-app/src/server/PagesRouteParams.ts +146 -0
  89. package/dist/templates/next-app/src/server/PasswordEncrypt.ts +8 -2
  90. package/dist/templates/next-app/src/server/ServerAuth.ts +20 -5
  91. package/dist/templates/next-app/src/server/{sqlBridges/SupabaseBridge.ts → SupabaseBridge.ts} +50 -8
  92. package/dist/templates/next-app/src/server/UserCredentialToken.ts +8 -2
  93. package/dist/templates/next-app/src/server/controllers/AdminLocalesController.ts +86 -0
  94. package/dist/templates/next-app/src/server/controllers/AdminUserController.ts +42 -0
  95. package/dist/templates/next-app/src/server/controllers/LocalesController.ts +36 -0
  96. package/dist/templates/next-app/src/server/controllers/UserController.ts +86 -0
  97. package/dist/templates/next-app/src/server/port/AIControllerInterface.ts +8 -0
  98. package/dist/templates/next-app/src/server/port/AdminLocalesControllerInterface.ts +21 -0
  99. package/dist/templates/next-app/src/server/port/AdminUserControllerInterface.ts +11 -0
  100. package/dist/templates/next-app/src/server/port/LocalesControllerInterface.ts +10 -0
  101. package/dist/templates/next-app/src/server/port/{ParamsHandlerInterface.ts → RouteParamsnHandlerInterface.ts} +9 -2
  102. package/dist/templates/next-app/src/server/port/ServerInterface.ts +2 -2
  103. package/dist/templates/next-app/src/server/port/UserControllerInerface.ts +8 -0
  104. package/dist/templates/next-app/src/server/port/UserServiceInterface.ts +1 -1
  105. package/dist/templates/next-app/src/server/port/ValidatorInterface.ts +2 -2
  106. package/dist/templates/next-app/src/server/repositorys/LocalesRepository.ts +31 -9
  107. package/dist/templates/next-app/src/server/repositorys/UserRepository.ts +15 -6
  108. package/dist/templates/next-app/src/server/services/AIService.ts +3 -1
  109. package/dist/templates/next-app/src/server/services/AdminAuthPlugin.ts +5 -2
  110. package/dist/templates/next-app/src/{base → server}/services/AdminLocalesService.ts +2 -2
  111. package/dist/templates/next-app/src/server/services/ApiLocaleService.ts +29 -14
  112. package/dist/templates/next-app/src/server/services/ApiUserService.ts +6 -3
  113. package/dist/templates/next-app/src/server/services/UserService.ts +12 -3
  114. package/dist/templates/next-app/src/server/validators/LocalesValidator.ts +24 -7
  115. package/dist/templates/next-app/src/server/validators/LoginValidator.ts +17 -5
  116. package/dist/templates/next-app/src/server/validators/PaginationValidator.ts +17 -11
  117. package/dist/templates/next-app/src/styles/css/antd-themes/_common/_default.css +0 -44
  118. package/dist/templates/next-app/src/styles/css/antd-themes/_common/dark.css +0 -44
  119. package/dist/templates/next-app/src/styles/css/antd-themes/_common/pink.css +0 -44
  120. package/dist/templates/next-app/src/styles/css/index.css +1 -1
  121. package/dist/templates/next-app/src/styles/css/scrollbar.css +34 -0
  122. package/dist/templates/next-app/src/uikit/components/AdminLayout.tsx +34 -11
  123. package/dist/templates/next-app/src/uikit/components/BootstrapsProvider.tsx +69 -39
  124. package/dist/templates/next-app/src/uikit/components/ClientRootProvider.tsx +64 -0
  125. package/dist/templates/next-app/src/uikit/components/ClinetRenderProvider.tsx +42 -0
  126. package/dist/templates/next-app/src/uikit/components/IOCProvider.tsx +34 -0
  127. package/dist/templates/next-app/src/uikit/components/localesImportButton/LocalesImportEvent.ts +7 -1
  128. package/dist/templates/next-app/src/uikit/components-app/AppBridge.tsx +17 -0
  129. package/dist/templates/next-app/src/uikit/components-app/AppRoutePage.tsx +112 -0
  130. package/dist/templates/next-app/src/uikit/{components → components-app}/LanguageSwitcher.tsx +15 -19
  131. package/dist/templates/next-app/src/uikit/{components → components-app}/ThemeSwitcher.tsx +53 -52
  132. package/dist/templates/next-app/src/uikit/components-pages/LanguageSwitcher.tsx +98 -0
  133. package/dist/templates/next-app/src/uikit/components-pages/PagesRoutePage.tsx +93 -0
  134. package/dist/templates/next-app/src/uikit/context/IOCContext.ts +16 -4
  135. package/dist/templates/next-app/src/uikit/hook/useStrictEffect.ts +32 -0
  136. package/dist/templates/next-app/tsconfig.json +3 -2
  137. package/dist/templates/react-app/__tests__/__mocks__/BootstrapTest.ts +3 -1
  138. package/dist/templates/react-app/__tests__/__mocks__/MockAppConfig.ts +19 -19
  139. package/dist/templates/react-app/__tests__/__mocks__/MockDialogHandler.ts +8 -8
  140. package/dist/templates/react-app/__tests__/__mocks__/MockLogger.ts +9 -9
  141. package/dist/templates/react-app/__tests__/__mocks__/components/TestBootstrapsProvider.tsx +1 -1
  142. package/dist/templates/react-app/__tests__/__mocks__/i18nextHttpBackend.ts +5 -5
  143. package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOC.ts +9 -5
  144. package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOCRegister.ts +8 -4
  145. package/dist/templates/react-app/__tests__/src/base/cases/I18nKeyErrorPlugin.test.ts +4 -4
  146. package/dist/templates/react-app/__tests__/src/base/cases/InversifyContainer.test.ts +5 -5
  147. package/dist/templates/react-app/__tests__/src/core/bootstraps/BootstrapClient.test.ts +3 -3
  148. package/dist/templates/react-app/__tests__/src/uikit/components/chatMessage/ChatRoot.test.tsx +1 -1
  149. package/dist/templates/react-app/docs/en/components/chat-message-component.md +35 -29
  150. package/dist/templates/react-app/docs/en/components/chat-message-refactor.md +18 -5
  151. package/dist/templates/react-app/docs/en/components/message-base-list-component.md +11 -12
  152. package/dist/templates/react-app/docs/en/request.md +1 -3
  153. package/dist/templates/react-app/docs/zh/components/chat-message-component.md +35 -29
  154. package/dist/templates/react-app/docs/zh/components/chat-message-refactor.md +18 -5
  155. package/dist/templates/react-app/docs/zh/components/message-base-list-component.md +11 -12
  156. package/dist/templates/react-app/docs/zh/request.md +1 -3
  157. package/dist/templates/react-app/eslint.config.mjs +10 -5
  158. package/dist/templates/react-app/src/App.tsx +1 -1
  159. package/dist/templates/react-app/src/base/apis/feApi/FeApi.ts +2 -2
  160. package/dist/templates/react-app/src/base/apis/feApi/FeApiBootstarp.ts +14 -11
  161. package/dist/templates/react-app/src/base/apis/userApi/UserApi.ts +10 -16
  162. package/dist/templates/react-app/src/base/apis/userApi/UserApiBootstarp.ts +12 -10
  163. package/dist/templates/react-app/src/base/cases/AppConfig.ts +19 -19
  164. package/dist/templates/react-app/src/base/cases/DialogHandler.ts +28 -5
  165. package/dist/templates/react-app/src/base/cases/I18nKeyErrorPlugin.ts +5 -2
  166. package/dist/templates/react-app/src/base/cases/InversifyContainer.ts +16 -4
  167. package/dist/templates/react-app/src/base/cases/PublicAssetsPath.ts +1 -1
  168. package/dist/templates/react-app/src/base/cases/RequestLanguages.ts +6 -3
  169. package/dist/templates/react-app/src/base/cases/RequestLogger.ts +17 -8
  170. package/dist/templates/react-app/src/base/cases/RequestStatusCatcher.ts +4 -6
  171. package/dist/templates/react-app/src/base/cases/ResourceState.ts +3 -3
  172. package/dist/templates/react-app/src/base/cases/RouterLoader.ts +3 -3
  173. package/dist/templates/react-app/src/base/cases/TranslateI18nInterface.ts +1 -1
  174. package/dist/templates/react-app/src/base/port/ExecutorPageBridgeInterface.ts +2 -2
  175. package/dist/templates/react-app/src/base/port/IOCInterface.ts +4 -2
  176. package/dist/templates/react-app/src/base/port/JSONStoragePageBridgeInterface.ts +5 -5
  177. package/dist/templates/react-app/src/base/port/RequestPageBridgeInterface.ts +7 -7
  178. package/dist/templates/react-app/src/base/port/RouteServiceInterface.ts +8 -8
  179. package/dist/templates/react-app/src/base/port/UserServiceInterface.ts +4 -2
  180. package/dist/templates/react-app/src/base/services/BaseLayoutService.ts +3 -3
  181. package/dist/templates/react-app/src/base/services/I18nService.ts +24 -13
  182. package/dist/templates/react-app/src/base/services/IdentifierService.ts +21 -26
  183. package/dist/templates/react-app/src/base/services/RouteService.ts +8 -8
  184. package/dist/templates/react-app/src/base/services/UserBootstrap.ts +2 -2
  185. package/dist/templates/react-app/src/base/services/UserGatewayPlugin.ts +9 -5
  186. package/dist/templates/react-app/src/base/services/UserService.ts +10 -4
  187. package/dist/templates/react-app/src/core/bootstraps/BootstrapClient.ts +3 -1
  188. package/dist/templates/react-app/src/core/bootstraps/BootstrapsRegistry.ts +5 -2
  189. package/dist/templates/react-app/src/core/clientIoc/ClientIOC.ts +11 -4
  190. package/dist/templates/react-app/src/core/clientIoc/ClientIOCRegister.ts +5 -4
  191. package/dist/templates/react-app/src/pages/base/Layout.tsx +1 -1
  192. package/dist/templates/react-app/src/styles/css/antd-themes/_common/_default.css +0 -44
  193. package/dist/templates/react-app/src/styles/css/antd-themes/_common/dark.css +0 -44
  194. package/dist/templates/react-app/src/styles/css/antd-themes/_common/pink.css +0 -44
  195. package/dist/templates/react-app/src/styles/css/index.css +1 -1
  196. package/dist/templates/react-app/src/styles/css/scrollbar.css +34 -0
  197. package/dist/templates/react-app/src/uikit/bridges/ExecutorPageBridge.ts +2 -2
  198. package/dist/templates/react-app/src/uikit/bridges/JSONStoragePageBridge.ts +4 -4
  199. package/dist/templates/react-app/src/uikit/bridges/NavigateBridge.ts +8 -2
  200. package/dist/templates/react-app/src/uikit/bridges/RequestPageBridge.ts +6 -6
  201. package/dist/templates/react-app/src/uikit/components/AppRouterProvider.tsx +1 -1
  202. package/dist/templates/react-app/src/uikit/components/BootstrapsProvider.tsx +1 -3
  203. package/dist/templates/react-app/src/uikit/components/MessageBaseList.tsx +4 -1
  204. package/dist/templates/react-app/src/uikit/components/chatMessage/ChatMessageBridge.ts +39 -16
  205. package/dist/templates/react-app/src/uikit/components/chatMessage/MessageApi.ts +4 -2
  206. package/package.json +3 -3
  207. package/dist/templates/next-app/src/server/PageParams.ts +0 -66
  208. package/dist/templates/next-app/src/uikit/components/BaseHeader.tsx +0 -80
  209. package/dist/templates/next-app/src/uikit/components/BaseLayout.tsx +0 -65
  210. package/dist/templates/next-app/src/uikit/components/ComboProvider.tsx +0 -58
  211. package/dist/templates/next-app/src/uikit/components/NextIntlProvider.tsx +0 -21
  212. package/dist/templates/react-app/makes/eslint-utils.mjs +0 -195
  213. /package/dist/templates/next-app/{src/app/[locale] → public}/favicon.ico +0 -0
  214. /package/dist/templates/next-app/src/uikit/{components → components-app}/LogoutButton.tsx +0 -0
@@ -11,12 +11,14 @@
11
11
  **文件:** `src/uikit/components/chatMessage/ChatRoot.tsx`
12
12
 
13
13
  **改动:**
14
+
14
15
  - 移除了内部的 `ChatMessageStore`、`MessageApi` 和 `ChatMessageBridge` 创建逻辑
15
16
  - 改为接收 `bridge` 和 `tt`(国际化对象)作为 props
16
17
  - 添加了 `ChatRootProps` 接口定义
17
18
  - 移除了内部的 `useI18nInterface` 调用
18
19
 
19
20
  **改造前:**
21
+
20
22
  ```typescript
21
23
  export function ChatRoot() {
22
24
  const messagesStore = useFactory(ChatMessageStore<string>);
@@ -29,7 +31,7 @@ export function ChatRoot() {
29
31
  gatewayOptions: { stream: true }
30
32
  }).use(new ChatSenderStrategy(SendFailureStrategy.KEEP_FAILED, logger));
31
33
  });
32
-
34
+
33
35
  return (
34
36
  <div data-testid="ChatRoot">
35
37
  <MessagesList bridge={bridge} />
@@ -40,6 +42,7 @@ export function ChatRoot() {
40
42
  ```
41
43
 
42
44
  **改造后:**
45
+
43
46
  ```typescript
44
47
  export interface ChatRootProps {
45
48
  bridge: ChatMessageBridge<string>;
@@ -61,12 +64,14 @@ export function ChatRoot({ bridge, tt }: ChatRootProps) {
61
64
  **文件:** `src/pages/base/MessagePage.tsx`
62
65
 
63
66
  **改动:**
67
+
64
68
  - 在 MessagePage 中使用 `useI18nInterface` 获取国际化对象 `tt`
65
69
  - 在 MessagePage 中创建 `ChatMessageStore`、`MessageApi` 和 `ChatMessageBridge`
66
70
  - 将 `bridge` 和 `tt` 通过 props 传递给 `ChatRoot` 组件
67
71
  - 同时集成了 `MessageBaseList` 组件
68
72
 
69
73
  **实现:**
74
+
70
75
  ```typescript
71
76
  import { useFactory } from '@brain-toolkit/react-kit';
72
77
  import { chatMessageI18n } from '@config/i18n/chatMessageI18n';
@@ -112,11 +117,13 @@ export default function MessagePage() {
112
117
  ### 3. 子组件改造(MessagesList、FocusBar、MessageItem)
113
118
 
114
119
  **改动:**
120
+
115
121
  - 移除了所有子组件内部的 `useI18nInterface` 调用
116
122
  - 改为通过 props 接收 `tt` 参数
117
123
  - 更新了各组件的 Props 接口定义
118
124
 
119
125
  **示例 - MessagesList:**
126
+
120
127
  ```typescript
121
128
  // 改造前
122
129
  export function MessagesList({ bridge, ... }: MessagesListProps) {
@@ -139,37 +146,44 @@ export function MessagesList({ bridge, tt, ... }: MessagesListProps) {
139
146
  ### 4. 删除独立的 ChatMessagePage
140
147
 
141
148
  **删除的文件:**
149
+
142
150
  - `src/pages/base/ChatMessagePage.tsx`
143
151
  - `config/Identifier/pages/page.chat.ts`
144
152
  - `config/i18n/chatI18n.ts`
145
153
 
146
154
  **更新的文件:**
155
+
147
156
  - `config/app.router.ts` - 移除了 `/chat` 路由配置
148
157
  - `config/Identifier/pages/index.ts` - 移除了 `page.chat` 导出
149
158
 
150
159
  ## 重构优势
151
160
 
152
161
  ### 1. 提高组件复用性
162
+
153
163
  - `ChatRoot` 现在是一个纯展示组件,可以在任何地方使用
154
164
  - `bridge` 和 `tt` 的创建和配置由父组件控制,更加灵活
155
165
  - 父组件可以自定义国际化内容,支持不同语言环境
156
166
 
157
167
  ### 2. 简化路由结构
168
+
158
169
  - 减少了不必要的路由层级
159
170
  - 将聊天功能直接集成到消息页面中,符合业务逻辑
160
171
 
161
172
  ### 3. 更好的关注点分离
173
+
162
174
  - `ChatRoot` 及其子组件只关注 UI 展示
163
175
  - 业务逻辑(store、api、bridge)在页面层管理
164
176
  - 国际化配置在页面层统一管理
165
177
  - 更容易测试和维护
166
178
 
167
179
  ### 4. 减少样板代码
180
+
168
181
  - 不需要为聊天功能创建单独的页面
169
182
  - 不需要为页面创建单独的 i18n 配置
170
183
  - 子组件不需要重复调用 `useI18nInterface`
171
184
 
172
185
  ### 5. 提升性能
186
+
173
187
  - 减少了 hook 调用次数(多个子组件共享同一个 `tt` 对象)
174
188
  - 避免了重复的国际化配置解析
175
189
 
@@ -197,7 +211,7 @@ import { MessageApi } from '@/uikit/components/chatMessage/MessageApi';
197
211
  function MyCustomChatPage() {
198
212
  // 获取国际化对象
199
213
  const tt = useI18nInterface(chatMessageI18n);
200
-
214
+
201
215
  const messagesStore = useFactory(ChatMessageStore<string>);
202
216
  const messageApi = useFactory(MessageApi, messagesStore);
203
217
 
@@ -206,7 +220,7 @@ function MyCustomChatPage() {
206
220
  gateway: messageApi,
207
221
  logger: logger,
208
222
  senderName: 'MyCustomSender',
209
- gatewayOptions: {
223
+ gatewayOptions: {
210
224
  stream: true,
211
225
  // 可以自定义其他选项
212
226
  }
@@ -241,7 +255,7 @@ const customI18n: ChatMessageI18nInterface = {
241
255
  function MyCustomChatPage() {
242
256
  const tt = useI18nInterface(customI18n);
243
257
  // ... 其他逻辑
244
-
258
+
245
259
  return <ChatRoot bridge={bridge} tt={tt} />;
246
260
  }
247
261
  ```
@@ -267,4 +281,3 @@ function MyCustomChatPage() {
267
281
  - [ChatMessage 组件文档](./chat-message-component.md)
268
282
  - [MessagePage 简化说明](./message-page-简化说明.md)
269
283
  - [开发指南](./development-guide.md)
270
-
@@ -52,17 +52,17 @@ export default function MessagePage() {
52
52
 
53
53
  ### 支持的文本
54
54
 
55
- | 文本项 | 中文 | 英文 |
56
- |--------|------|------|
57
- | 标题 | 消息网关测试 | Message Gateway Test |
58
- | 描述 | 发送消息并等待网关响应 | Send messages and wait for gateway response |
59
- | 空状态 | 暂无消息 | No messages yet |
60
- | 用户标签 | 你 | You |
61
- | 网关标签 | 网关 | Gateway |
62
- | 处理中 | 处理中... | Processing... |
63
- | 失败标签 | 网关(失败) | Gateway (Failed) |
64
- | 网关响应 | 网关响应 | Gateway Response |
65
- | 发送按钮 | 发送 | Send |
55
+ | 文本项 | 中文 | 英文 |
56
+ | -------- | ---------------------- | ------------------------------------------- |
57
+ | 标题 | 消息网关测试 | Message Gateway Test |
58
+ | 描述 | 发送消息并等待网关响应 | Send messages and wait for gateway response |
59
+ | 空状态 | 暂无消息 | No messages yet |
60
+ | 用户标签 | 你 | You |
61
+ | 网关标签 | 网关 | Gateway |
62
+ | 处理中 | 处理中... | Processing... |
63
+ | 失败标签 | 网关(失败) | Gateway (Failed) |
64
+ | 网关响应 | 网关响应 | Gateway Response |
65
+ | 发送按钮 | 发送 | Send |
66
66
 
67
67
  ## 🧪 测试功能
68
68
 
@@ -169,4 +169,3 @@ UI 自动更新显示
169
169
  ## 🎉 总结
170
170
 
171
171
  `MessageBaseList` 是一个功能完整、样式美观的消息组件,完全支持国际化,适合用于测试和展示消息网关功能。
172
-
@@ -158,9 +158,7 @@ apiAdapter.usePlugin(new ApiMockPlugin(mockDataJson, logger));
158
158
 
159
159
  ```typescript
160
160
  @injectable()
161
- export class RequestLogger
162
- implements ExecutorPlugin<RequestAdapterFetchConfig>
163
- {
161
+ export class RequestLogger implements ExecutorPlugin<RequestAdapterFetchConfig> {
164
162
  readonly pluginName = 'RequestLogger';
165
163
 
166
164
  onBefore(context) {
@@ -4,10 +4,9 @@ import { FlatCompat } from '@eslint/eslintrc';
4
4
  import importPlugin from 'eslint-plugin-import';
5
5
  import prettierPlugin from 'eslint-plugin-prettier';
6
6
  import unusedImports from 'eslint-plugin-unused-imports';
7
- import qloverEslint from '@qlover/eslint-plugin';
7
+ import qloverEslint, { restrictSpecificGlobals } from '@qlover/eslint-plugin';
8
8
  import tseslint from 'typescript-eslint';
9
9
  import globals from 'globals';
10
- import { restrictSpecificGlobals } from './makes/eslint-utils.mjs';
11
10
 
12
11
  const __filename = fileURLToPath(import.meta.url);
13
12
  const __dirname = dirname(__filename);
@@ -80,7 +79,7 @@ const eslintConfig = [
80
79
  'jest.config.*',
81
80
  'babel.config.*',
82
81
  'playwright.config.*',
83
-
82
+
84
83
  // static assets
85
84
  'public/**',
86
85
  '**/*.min.js',
@@ -116,8 +115,14 @@ const eslintConfig = [
116
115
  },
117
116
  rules: {
118
117
  '@qlover-eslint/ts-class-method-return': 'error',
119
- '@qlover-eslint/require-root-testid': 'error',
120
- // 禁用 import 路径解析检查,TypeScript 编译器会处理
118
+ '@qlover-eslint/ts-class-member-accessibility': 'error',
119
+ '@qlover-eslint/ts-class-override': 'error',
120
+ '@qlover-eslint/require-root-testid': [
121
+ 'error',
122
+ {
123
+ exclude: ['/Provider$/']
124
+ }
125
+ ], // 禁用 import 路径解析检查,TypeScript 编译器会处理
121
126
  'import/no-unresolved': 'off',
122
127
  // 禁用原始的 no-unused-vars,使用 unused-imports 的规则替代
123
128
  '@typescript-eslint/no-unused-vars': 'off',
@@ -24,7 +24,7 @@ const allPages = (function getAllPages() {
24
24
 
25
25
  function App() {
26
26
  return (
27
- <BootstrapsProvider data-testid="App">
27
+ <BootstrapsProvider>
28
28
  <ComboProvider themeConfig={themeConfig}>
29
29
  <AppRouterProvider pages={allPages} />
30
30
  </ComboProvider>
@@ -10,9 +10,9 @@ export class FeApi extends RequestScheduler<FeApiConfig> {
10
10
  super(adapter);
11
11
  }
12
12
 
13
- stop(_config: FeApiConfig): void {}
13
+ public stop(_config: FeApiConfig): void {}
14
14
 
15
- async getIpInfo(): Promise<FeApiGetIpInfo['response']> {
15
+ public async getIpInfo(): Promise<FeApiGetIpInfo['response']> {
16
16
  return this.get('http://ip-api.com/json/') as unknown as Promise<
17
17
  FeApiGetIpInfo['response']
18
18
  >;
@@ -23,8 +23,7 @@ import type {
23
23
  * extends:
24
24
  */
25
25
  export interface FeApiConfig<Request = unknown>
26
- extends RequestAdapterConfig<Request>,
27
- ApiMockPluginConfig {}
26
+ extends RequestAdapterConfig<Request>, ApiMockPluginConfig {}
28
27
 
29
28
  /**
30
29
  * FeApiResponse
@@ -35,8 +34,10 @@ export interface FeApiConfig<Request = unknown>
35
34
  * extends:
36
35
  * - RequestAdapterResponse<Request, Response>
37
36
  */
38
- export interface FeApiResponse<Request = unknown, Response = unknown>
39
- extends RequestAdapterResponse<Request, Response> {}
37
+ export interface FeApiResponse<
38
+ Request = unknown,
39
+ Response = unknown
40
+ > extends RequestAdapterResponse<Request, Response> {}
40
41
 
41
42
  /**
42
43
  * FeApi common transaction
@@ -45,18 +46,20 @@ export interface FeApiResponse<Request = unknown, Response = unknown>
45
46
  *
46
47
  * add data property
47
48
  */
48
- export interface FeApiTransaction<Request = unknown, Response = unknown>
49
- extends RequestTransactionInterface<
50
- FeApiConfig<Request>,
51
- FeApiResponse<Request, Response>['data']
52
- > {
49
+ export interface FeApiTransaction<
50
+ Request = unknown,
51
+ Response = unknown
52
+ > extends RequestTransactionInterface<
53
+ FeApiConfig<Request>,
54
+ FeApiResponse<Request, Response>['data']
55
+ > {
53
56
  data: FeApiConfig<Request>['data'];
54
57
  }
55
58
 
56
59
  export class FeApiBootstarp implements BootstrapExecutorPlugin {
57
- readonly pluginName = 'FeApiBootstarp';
60
+ public readonly pluginName = 'FeApiBootstarp';
58
61
 
59
- onBefore({ parameters: { ioc } }: BootstrapContext): void {
62
+ public onBefore({ parameters: { ioc } }: BootstrapContext): void {
60
63
  ioc
61
64
  .get<FeApi>(FeApi)
62
65
  .usePlugin(new FetchURLPlugin())
@@ -43,23 +43,22 @@ export class UserApi
43
43
  super(adapter);
44
44
  }
45
45
 
46
- getStore(): UserAuthStoreInterface<UserInfo> | null {
46
+ public getStore(): UserAuthStoreInterface<UserInfo> | null {
47
47
  return this.store;
48
48
  }
49
49
 
50
50
  /**
51
- * @override
52
51
  * @param store
53
52
  */
54
- setStore(store: UserAuthStoreInterface<UserInfo>): void {
53
+ public setStore(store: UserAuthStoreInterface<UserInfo>): void {
55
54
  this.store = store;
56
55
  }
57
56
 
58
- stop(request: UserApiConfig): Promise<void> | void {
57
+ public stop(request: UserApiConfig): Promise<void> | void {
59
58
  this.abortPlugin.abort(request);
60
59
  }
61
60
 
62
- async getRandomUser(): Promise<GetIpInfoTransaction['response']> {
61
+ public async getRandomUser(): Promise<GetIpInfoTransaction['response']> {
63
62
  return this.request<GetIpInfoTransaction>({
64
63
  url: 'https://randomuser.me/api/',
65
64
  method: 'GET',
@@ -67,7 +66,7 @@ export class UserApi
67
66
  });
68
67
  }
69
68
 
70
- async testApiCatchResult(): Promise<
69
+ public async testApiCatchResult(): Promise<
71
70
  UserApiTestApiCatchResultTransaction['response']
72
71
  > {
73
72
  return this.request<UserApiTestApiCatchResultTransaction>({
@@ -79,11 +78,10 @@ export class UserApi
79
78
  }
80
79
 
81
80
  /**
82
- * @override
83
81
  * @param params
84
82
  * @returns
85
83
  */
86
- async login(
84
+ public async login(
87
85
  params: UserApiLoginTransaction['data']
88
86
  ): Promise<UserCredential> {
89
87
  const response = await this.post<UserApiLoginTransaction>(
@@ -103,11 +101,10 @@ export class UserApi
103
101
  }
104
102
 
105
103
  /**
106
- * @override
107
104
  * @param params
108
105
  * @returns
109
106
  */
110
- register(
107
+ public register(
111
108
  params: UserApiRegisterTransaction['data']
112
109
  ): Promise<UserApiRegisterTransaction['response']['data']> {
113
110
  // @ts-expect-error - TODO: implement
@@ -115,26 +112,23 @@ export class UserApi
115
112
  }
116
113
 
117
114
  /**
118
- * @override
119
115
  * @returns
120
116
  */
121
- async refreshUserInfo(): Promise<UserInfo> {
117
+ public async refreshUserInfo(): Promise<UserInfo> {
122
118
  return this.getUserInfo();
123
119
  }
124
120
 
125
121
  /**
126
- * @override
127
122
  * @returns
128
123
  */
129
- logout(): Promise<any> {
124
+ public logout(): Promise<any> {
130
125
  return this.post('/api/logout');
131
126
  }
132
127
 
133
128
  /**
134
- * @override
135
129
  * @returns
136
130
  */
137
- async getUserInfo(_credential?: UserCredential): Promise<UserInfo> {
131
+ public async getUserInfo(_credential?: UserCredential): Promise<UserInfo> {
138
132
  const response =
139
133
  await this.get<UserApiGetUserInfoTransaction>('/api/userinfo');
140
134
 
@@ -27,7 +27,8 @@ import type {
27
27
  * - ApiCatchPluginConfig
28
28
  */
29
29
  export interface UserApiConfig<Request = unknown>
30
- extends RequestAdapterConfig<Request>,
30
+ extends
31
+ RequestAdapterConfig<Request>,
31
32
  ApiMockPluginOptions,
32
33
  ApiCatchPluginConfig {}
33
34
 
@@ -41,8 +42,7 @@ export interface UserApiConfig<Request = unknown>
41
42
  * - RequestAdapterResponse<Request, Response>
42
43
  */
43
44
  export interface UserApiResponse<Request = unknown, Response = unknown>
44
- extends RequestAdapterResponse<Request, Response>,
45
- ApiCatchPluginResponse {}
45
+ extends RequestAdapterResponse<Request, Response>, ApiCatchPluginResponse {}
46
46
 
47
47
  /**
48
48
  * UserApi common transaction
@@ -51,18 +51,20 @@ export interface UserApiResponse<Request = unknown, Response = unknown>
51
51
  *
52
52
  * add data property
53
53
  */
54
- export interface UserApiTransaction<Request = unknown, Response = unknown>
55
- extends RequestTransactionInterface<
56
- UserApiConfig<Request>,
57
- UserApiResponse<Request, Response>
58
- > {
54
+ export interface UserApiTransaction<
55
+ Request = unknown,
56
+ Response = unknown
57
+ > extends RequestTransactionInterface<
58
+ UserApiConfig<Request>,
59
+ UserApiResponse<Request, Response>
60
+ > {
59
61
  data: UserApiConfig<Request>['data'];
60
62
  }
61
63
 
62
64
  export class UserApiBootstarp implements BootstrapExecutorPlugin {
63
- readonly pluginName = 'UserApiBootstarp';
65
+ public readonly pluginName = 'UserApiBootstarp';
64
66
 
65
- onBefore({ parameters: { ioc } }: BootstrapContext): void {
67
+ public onBefore({ parameters: { ioc } }: BootstrapContext): void {
66
68
  ioc
67
69
  .get<UserApi>(UserApi)
68
70
  .usePlugin(new FetchURLPlugin())
@@ -43,31 +43,31 @@ export class AppConfig implements EnvConfigInterface {
43
43
  * Application name identifier
44
44
  * @description Injected from VITE_APP_NAME environment variable
45
45
  */
46
- readonly appName = '';
46
+ public readonly appName = '';
47
47
 
48
48
  /**
49
49
  * Current version of the application
50
50
  * @description Injected from VITE_APP_VERSION environment variable
51
51
  */
52
- readonly appVersion = '';
52
+ public readonly appVersion = '';
53
53
 
54
54
  /**
55
55
  * Storage key for user authentication token
56
56
  * @description Injected from VITE_USER_TOKEN_STORAGE_KEY environment variable
57
57
  */
58
- readonly userTokenStorageKey = '__fe_user_token__';
58
+ public readonly userTokenStorageKey = '__fe_user_token__';
59
59
 
60
60
  /**
61
61
  * Storage key for user information
62
62
  * @description Injected from VITE_USER_INFO_STORAGE_KEY environment variable
63
63
  */
64
- readonly userInfoStorageKey = '__fe_user_info__';
64
+ public readonly userInfoStorageKey = '__fe_user_info__';
65
65
 
66
66
  /**
67
67
  * Available OpenAI model configurations
68
68
  * @description List of supported OpenAI models for the application
69
69
  */
70
- readonly openAiModels = [
70
+ public readonly openAiModels = [
71
71
  'gpt-4o-mini',
72
72
  'gpt-3.5-turbo',
73
73
  'gpt-3.5-turbo-2',
@@ -76,48 +76,48 @@ export class AppConfig implements EnvConfigInterface {
76
76
  ];
77
77
 
78
78
  /** Base URL for OpenAI API endpoints */
79
- readonly openAiBaseUrl = '';
79
+ public readonly openAiBaseUrl = '';
80
80
 
81
81
  /** Authentication token for OpenAI API */
82
- readonly openAiToken = '';
82
+ public readonly openAiToken = '';
83
83
 
84
84
  /** Prefix for OpenAI authentication token */
85
- readonly openAiTokenPrefix = '';
85
+ public readonly openAiTokenPrefix = '';
86
86
 
87
87
  /** Flag indicating if OpenAI token is required */
88
- readonly openAiRequireToken = true;
88
+ public readonly openAiRequireToken = true;
89
89
 
90
90
  /** Default login username */
91
- readonly loginUser = '';
91
+ public readonly loginUser = '';
92
92
 
93
93
  /** Default login password */
94
- readonly loginPassword = '';
94
+ public readonly loginPassword = '';
95
95
 
96
96
  /** Base URL for frontend API endpoints */
97
- readonly feApiBaseUrl = '';
97
+ public readonly feApiBaseUrl = '';
98
98
 
99
99
  /** Base URL for user-related API endpoints */
100
- readonly userApiBaseUrl = '';
100
+ public readonly userApiBaseUrl = '';
101
101
 
102
102
  /** Base URL for AI service API endpoints */
103
- readonly aiApiBaseUrl = 'https://api.openai.com/v1';
103
+ public readonly aiApiBaseUrl = 'https://api.openai.com/v1';
104
104
 
105
105
  /** Authentication token for AI service API */
106
- readonly aiApiToken = '';
106
+ public readonly aiApiToken = '';
107
107
 
108
108
  /** Prefix for AI service authentication token */
109
- readonly aiApiTokenPrefix = 'Bearer';
109
+ public readonly aiApiTokenPrefix = 'Bearer';
110
110
 
111
111
  /** Flag indicating if AI service token is required */
112
- readonly aiApiRequireToken = true;
112
+ public readonly aiApiRequireToken = true;
113
113
 
114
114
  /**
115
115
  * Project startup href, usually from window.location.href
116
116
  */
117
- readonly bootHref = '';
117
+ public readonly bootHref = '';
118
118
 
119
119
  /** Flag indicating if the current environment is production */
120
- get isProduction(): boolean {
120
+ public get isProduction(): boolean {
121
121
  return this.env === 'production';
122
122
  }
123
123
  }
@@ -11,8 +11,7 @@ import type {
11
11
  import type { ModalFuncProps } from 'antd';
12
12
 
13
13
  export interface DialogHandlerOptions
14
- extends NotificationOptions,
15
- ModalFuncProps {
14
+ extends NotificationOptions, ModalFuncProps {
16
15
  content: string;
17
16
  }
18
17
 
@@ -46,15 +45,24 @@ export class DialogHandler
46
45
  notification?: NotificationApi;
47
46
  } = {};
48
47
 
49
- setMessage(message: MessageApi): void {
48
+ /**
49
+ * @override
50
+ */
51
+ public setMessage(message: MessageApi): void {
50
52
  this.antds.message = message;
51
53
  }
52
54
 
53
- setModal(modal: ModalApi): void {
55
+ /**
56
+ * @override
57
+ */
58
+ public setModal(modal: ModalApi): void {
54
59
  this.antds.modal = modal;
55
60
  }
56
61
 
57
- setNotification(notification: NotificationApi): void {
62
+ /**
63
+ * @override
64
+ */
65
+ public setNotification(notification: NotificationApi): void {
58
66
  this.antds.notification = notification;
59
67
  }
60
68
 
@@ -67,10 +75,16 @@ export class DialogHandler
67
75
  return 'An unknown error occurred';
68
76
  }
69
77
 
78
+ /**
79
+ * @override
80
+ */
70
81
  public success(msg: string, options?: NotificationOptions): void {
71
82
  this.antds.message?.success({ content: msg, ...options });
72
83
  }
73
84
 
85
+ /**
86
+ * @override
87
+ */
74
88
  public error(msg: string, options?: NotificationOptions): void {
75
89
  this.antds.message?.error({
76
90
  content: options?.error ? this.formatErrorMessage(options.error) : msg,
@@ -78,14 +92,23 @@ export class DialogHandler
78
92
  });
79
93
  }
80
94
 
95
+ /**
96
+ * @override
97
+ */
81
98
  public info(msg: string, options?: NotificationOptions): void {
82
99
  this.antds.message?.info({ content: msg, ...options });
83
100
  }
84
101
 
102
+ /**
103
+ * @override
104
+ */
85
105
  public warn(msg: string, options?: NotificationOptions): void {
86
106
  this.antds.message?.warning({ content: msg, ...options });
87
107
  }
88
108
 
109
+ /**
110
+ * @override
111
+ */
89
112
  public confirm(options: DialogHandlerOptions): void {
90
113
  this.antds.modal?.confirm(options);
91
114
  }
@@ -15,7 +15,7 @@ import type { LoggerInterface } from '@qlover/logger';
15
15
  */
16
16
  @injectable()
17
17
  export class I18nKeyErrorPlugin implements ExecutorPlugin {
18
- readonly pluginName = 'I18nKeyErrorPlugin';
18
+ public readonly pluginName = 'I18nKeyErrorPlugin';
19
19
 
20
20
  constructor(
21
21
  @inject(IOCIdentifier.Logger) protected logger: LoggerInterface,
@@ -27,7 +27,10 @@ export class I18nKeyErrorPlugin implements ExecutorPlugin {
27
27
  return this.i18nService.t(id);
28
28
  }
29
29
 
30
- onError(context: ExecutorContext<unknown>): Error | void {
30
+ /**
31
+ * @override
32
+ */
33
+ public onError(context: ExecutorContext<unknown>): Error | void {
31
34
  const { error } = context;
32
35
 
33
36
  if (!error) {
@@ -17,15 +17,27 @@ export class InversifyContainer implements IOCContainerInterface {
17
17
  });
18
18
  }
19
19
 
20
- bind<T>(key: ServiceIdentifier<T>, value: T): void {
20
+ /**
21
+ * @override
22
+ */
23
+ public bind<T>(key: ServiceIdentifier<T>, value: T): void {
21
24
  this.container.bind<T>(key).toConstantValue(value);
22
25
  }
23
26
 
24
- get<K extends keyof IOCIdentifierMap>(
27
+ /**
28
+ * @override
29
+ */
30
+ public get<K extends keyof IOCIdentifierMap>(
25
31
  serviceIdentifier: K
26
32
  ): IOCIdentifierMap[K];
27
- get<T>(serviceIdentifier: ServiceIdentifier<T>): T;
28
- get<T, K extends keyof IOCIdentifierMap>(
33
+ /**
34
+ * @override
35
+ */
36
+ public get<T>(serviceIdentifier: ServiceIdentifier<T>): T;
37
+ /**
38
+ * @override
39
+ */
40
+ public get<T, K extends keyof IOCIdentifierMap>(
29
41
  serviceIdentifier: ServiceIdentifier<T> | K
30
42
  ): T | IOCIdentifierMap[K] {
31
43
  return this.container.get<T>(serviceIdentifier);
@@ -11,7 +11,7 @@ import { injectable } from 'inversify';
11
11
  export class PublicAssetsPath {
12
12
  constructor(protected prefix: string = routerPrefix) {}
13
13
 
14
- getPath(path: string): string {
14
+ public getPath(path: string): string {
15
15
  if (!this.prefix) {
16
16
  return path.startsWith('/') ? path : `/${path}`;
17
17
  }