@qlover/create-app 0.8.0 → 0.10.0

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 (85) hide show
  1. package/CHANGELOG.md +32 -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 +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/templates/next-app/.env.template +9 -10
  7. package/dist/templates/next-app/eslint.config.mjs +5 -0
  8. package/dist/templates/next-app/next.config.ts +1 -1
  9. package/dist/templates/next-app/src/app/[locale]/login/page.tsx +1 -1
  10. package/dist/templates/next-app/src/app/[locale]/page.tsx +1 -1
  11. package/dist/templates/next-app/src/app/[locale]/register/page.tsx +1 -1
  12. package/dist/templates/next-app/src/app/api/locales/json/route.ts +2 -1
  13. package/dist/templates/next-app/src/i18n/request.ts +2 -2
  14. package/dist/templates/react-app/__tests__/__mocks__/{MockAppConfit.ts → MockAppConfig.ts} +1 -1
  15. package/dist/templates/react-app/__tests__/__mocks__/components/TestApp.tsx +10 -17
  16. package/dist/templates/react-app/__tests__/__mocks__/components/TestBootstrapsProvider.tsx +27 -8
  17. package/dist/templates/react-app/__tests__/__mocks__/createMockGlobals.ts +1 -1
  18. package/dist/templates/react-app/__tests__/__mocks__/i18nextHttpBackend.ts +110 -0
  19. package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOCRegister.ts +3 -2
  20. package/dist/templates/react-app/__tests__/setup/setupGlobal.ts +13 -0
  21. package/dist/templates/react-app/__tests__/src/base/services/I18nService.test.ts +3 -1
  22. package/dist/templates/react-app/__tests__/src/uikit/components/chatMessage/ChatRoot.test.tsx +274 -0
  23. package/dist/templates/react-app/config/IOCIdentifier.ts +9 -3
  24. package/dist/templates/react-app/config/Identifier/components/component.chatMessage.ts +56 -0
  25. package/dist/templates/react-app/config/Identifier/components/component.messageBaseList.ts +103 -0
  26. package/dist/templates/react-app/config/Identifier/pages/index.ts +1 -0
  27. package/dist/templates/react-app/config/Identifier/pages/page.message.ts +20 -0
  28. package/dist/templates/react-app/config/app.router.ts +23 -0
  29. package/dist/templates/react-app/config/common.ts +38 -0
  30. package/dist/templates/react-app/config/feapi.mock.json +5 -12
  31. package/dist/templates/react-app/config/i18n/chatMessageI18n.ts +17 -0
  32. package/dist/templates/react-app/config/i18n/messageBaseListI18n.ts +22 -0
  33. package/dist/templates/react-app/config/i18n/messageI18n.ts +14 -0
  34. package/dist/templates/react-app/docs/en/components/chat-message-component.md +314 -0
  35. package/dist/templates/react-app/docs/en/components/chat-message-refactor.md +270 -0
  36. package/dist/templates/react-app/docs/en/components/message-base-list-component.md +172 -0
  37. package/dist/templates/react-app/docs/zh/components/chat-message-component.md +314 -0
  38. package/dist/templates/react-app/docs/zh/components/chat-message-refactor.md +270 -0
  39. package/dist/templates/react-app/docs/zh/components/message-base-list-component.md +172 -0
  40. package/dist/templates/react-app/eslint.config.mjs +6 -5
  41. package/dist/templates/react-app/package.json +1 -1
  42. package/dist/templates/react-app/playwright.config.ts +6 -6
  43. package/dist/templates/react-app/public/locales/en/common.json +44 -1
  44. package/dist/templates/react-app/public/locales/zh/common.json +44 -1
  45. package/dist/templates/react-app/src/base/apis/userApi/UserApi.ts +22 -13
  46. package/dist/templates/react-app/src/base/apis/userApi/UserApiBootstarp.ts +3 -3
  47. package/dist/templates/react-app/src/base/apis/userApi/UserApiType.ts +17 -12
  48. package/dist/templates/react-app/src/base/cases/I18nKeyErrorPlugin.ts +19 -2
  49. package/dist/templates/react-app/src/base/port/RouteServiceInterface.ts +2 -4
  50. package/dist/templates/react-app/src/base/port/UserServiceInterface.ts +15 -9
  51. package/dist/templates/react-app/src/base/services/BaseLayoutService.ts +55 -0
  52. package/dist/templates/react-app/src/base/services/I18nService.ts +1 -0
  53. package/dist/templates/react-app/src/base/services/UserBootstrap.ts +43 -0
  54. package/dist/templates/react-app/src/base/services/UserGatewayPlugin.ts +16 -0
  55. package/dist/templates/react-app/src/base/services/UserService.ts +51 -80
  56. package/dist/templates/react-app/src/core/bootstraps/BootstrapClient.ts +8 -3
  57. package/dist/templates/react-app/src/core/bootstraps/BootstrapsRegistry.ts +6 -6
  58. package/dist/templates/react-app/src/core/bootstraps/SaveAppInfo.ts +28 -0
  59. package/dist/templates/react-app/src/core/clientIoc/ClientIOCRegister.ts +24 -18
  60. package/dist/templates/react-app/src/core/globals.ts +10 -11
  61. package/dist/templates/react-app/src/main.tsx +1 -1
  62. package/dist/templates/react-app/src/pages/auth/Layout.tsx +4 -4
  63. package/dist/templates/react-app/src/pages/auth/RegisterPage.tsx +1 -1
  64. package/dist/templates/react-app/src/pages/base/Layout.tsx +3 -3
  65. package/dist/templates/react-app/src/pages/base/MessagePage.tsx +40 -0
  66. package/dist/templates/react-app/src/uikit/components/BaseLayoutProvider.tsx +44 -0
  67. package/dist/templates/react-app/src/uikit/components/LogoutButton.tsx +1 -3
  68. package/dist/templates/react-app/src/uikit/components/MessageBaseList.tsx +240 -0
  69. package/dist/templates/react-app/src/uikit/components/chatMessage/ChatMessageBridge.ts +176 -0
  70. package/dist/templates/react-app/src/uikit/components/chatMessage/ChatRoot.tsx +21 -0
  71. package/dist/templates/react-app/src/uikit/components/chatMessage/FocusBar.tsx +106 -0
  72. package/dist/templates/react-app/src/uikit/components/chatMessage/MessageApi.ts +271 -0
  73. package/dist/templates/react-app/src/uikit/components/chatMessage/MessageItem.tsx +102 -0
  74. package/dist/templates/react-app/src/uikit/components/chatMessage/MessagesList.tsx +86 -0
  75. package/dist/templates/react-app/src/uikit/hooks/useNavigateBridge.ts +9 -0
  76. package/dist/templates/react-app/src/uikit/hooks/{useI18nGuard.ts → useRouterI18nGuard.ts} +7 -4
  77. package/dist/templates/react-app/tsconfig.app.json +4 -2
  78. package/dist/templates/react-app/tsconfig.node.json +4 -0
  79. package/dist/templates/react-app/tsconfig.test.json +3 -1
  80. package/package.json +3 -3
  81. package/dist/templates/react-app/__tests__/src/base/cases/AppError.test.ts +0 -102
  82. package/dist/templates/react-app/__tests__/src/main.integration.test.tsx +0 -61
  83. package/dist/templates/react-app/src/base/services/ProcesserExecutor.ts +0 -57
  84. package/dist/templates/react-app/src/uikit/components/ProcessExecutorProvider.tsx +0 -28
  85. package/dist/templates/react-app/src/uikit/components/UserAuthProvider.tsx +0 -16
@@ -0,0 +1,270 @@
1
+ # ChatMessage 重构说明
2
+
3
+ ## 重构内容
4
+
5
+ 将 ChatMessage 从独立页面重构为可复用组件,集成到 MessagePage 中,并通过 props 传递国际化对象 `tt`,确保组件的高度可复用性。
6
+
7
+ ## 改动说明
8
+
9
+ ### 1. ChatRoot 组件改造
10
+
11
+ **文件:** `src/uikit/components/chatMessage/ChatRoot.tsx`
12
+
13
+ **改动:**
14
+ - 移除了内部的 `ChatMessageStore`、`MessageApi` 和 `ChatMessageBridge` 创建逻辑
15
+ - 改为接收 `bridge` 和 `tt`(国际化对象)作为 props
16
+ - 添加了 `ChatRootProps` 接口定义
17
+ - 移除了内部的 `useI18nInterface` 调用
18
+
19
+ **改造前:**
20
+ ```typescript
21
+ export function ChatRoot() {
22
+ const messagesStore = useFactory(ChatMessageStore<string>);
23
+ const messageApi = useFactory(MessageApi, messagesStore);
24
+ const [bridge] = useState(() => {
25
+ return new ChatMessageBridge<string>(messagesStore, {
26
+ gateway: messageApi,
27
+ logger: logger,
28
+ senderName: 'ChatSender',
29
+ gatewayOptions: { stream: true }
30
+ }).use(new ChatSenderStrategy(SendFailureStrategy.KEEP_FAILED, logger));
31
+ });
32
+
33
+ return (
34
+ <div data-testid="ChatRoot">
35
+ <MessagesList bridge={bridge} />
36
+ <FocusBar bridge={bridge} />
37
+ </div>
38
+ );
39
+ }
40
+ ```
41
+
42
+ **改造后:**
43
+ ```typescript
44
+ export interface ChatRootProps {
45
+ bridge: ChatMessageBridge<string>;
46
+ tt: ChatMessageI18nInterface;
47
+ }
48
+
49
+ export function ChatRoot({ bridge, tt }: ChatRootProps) {
50
+ return (
51
+ <div data-testid="ChatRoot">
52
+ <MessagesList bridge={bridge} tt={tt} />
53
+ <FocusBar bridge={bridge} tt={tt} />
54
+ </div>
55
+ );
56
+ }
57
+ ```
58
+
59
+ ### 2. MessagePage 集成 ChatRoot
60
+
61
+ **文件:** `src/pages/base/MessagePage.tsx`
62
+
63
+ **改动:**
64
+ - 在 MessagePage 中使用 `useI18nInterface` 获取国际化对象 `tt`
65
+ - 在 MessagePage 中创建 `ChatMessageStore`、`MessageApi` 和 `ChatMessageBridge`
66
+ - 将 `bridge` 和 `tt` 通过 props 传递给 `ChatRoot` 组件
67
+ - 同时集成了 `MessageBaseList` 组件
68
+
69
+ **实现:**
70
+ ```typescript
71
+ import { useFactory } from '@brain-toolkit/react-kit';
72
+ import { chatMessageI18n } from '@config/i18n/chatMessageI18n';
73
+ import {
74
+ ChatMessageStore,
75
+ ChatSenderStrategy,
76
+ SendFailureStrategy
77
+ } from '@qlover/corekit-bridge';
78
+ import { useState } from 'react';
79
+ import { logger } from '@/core/globals';
80
+ import { ChatMessageBridge } from '@/uikit/components/chatMessage/ChatMessageBridge';
81
+ import { ChatRoot } from '@/uikit/components/chatMessage/ChatRoot';
82
+ import { MessageApi } from '@/uikit/components/chatMessage/MessageApi';
83
+ import { MessageBaseList } from '@/uikit/components/MessageBaseList';
84
+ import { useI18nInterface } from '@/uikit/hooks/useI18nInterface';
85
+
86
+ export default function MessagePage() {
87
+ const tt = useI18nInterface(chatMessageI18n);
88
+ const messagesStore = useFactory(ChatMessageStore<string>);
89
+ const messageApi = useFactory(MessageApi, messagesStore);
90
+
91
+ const [bridge] = useState(() => {
92
+ return new ChatMessageBridge<string>(messagesStore, {
93
+ gateway: messageApi,
94
+ logger: logger,
95
+ senderName: 'ChatSender',
96
+ gatewayOptions: { stream: true }
97
+ }).use(new ChatSenderStrategy(SendFailureStrategy.KEEP_FAILED, logger));
98
+ });
99
+
100
+ return (
101
+ <div
102
+ data-testid="MessagePage"
103
+ className="min-h-screen bg-primary py-8 px-4 sm:px-6 lg:px-8"
104
+ >
105
+ <MessageBaseList />
106
+ <ChatRoot bridge={bridge} tt={tt} />
107
+ </div>
108
+ );
109
+ }
110
+ ```
111
+
112
+ ### 3. 子组件改造(MessagesList、FocusBar、MessageItem)
113
+
114
+ **改动:**
115
+ - 移除了所有子组件内部的 `useI18nInterface` 调用
116
+ - 改为通过 props 接收 `tt` 参数
117
+ - 更新了各组件的 Props 接口定义
118
+
119
+ **示例 - MessagesList:**
120
+ ```typescript
121
+ // 改造前
122
+ export function MessagesList({ bridge, ... }: MessagesListProps) {
123
+ const tt = useI18nInterface(chatMessageI18n);
124
+ // ...
125
+ }
126
+
127
+ // 改造后
128
+ export interface MessagesListProps {
129
+ bridge: ChatMessageBridgeInterface<T>;
130
+ tt: ChatMessageI18nInterface;
131
+ // ...
132
+ }
133
+
134
+ export function MessagesList({ bridge, tt, ... }: MessagesListProps) {
135
+ // 直接使用传入的 tt
136
+ }
137
+ ```
138
+
139
+ ### 4. 删除独立的 ChatMessagePage
140
+
141
+ **删除的文件:**
142
+ - `src/pages/base/ChatMessagePage.tsx`
143
+ - `config/Identifier/pages/page.chat.ts`
144
+ - `config/i18n/chatI18n.ts`
145
+
146
+ **更新的文件:**
147
+ - `config/app.router.ts` - 移除了 `/chat` 路由配置
148
+ - `config/Identifier/pages/index.ts` - 移除了 `page.chat` 导出
149
+
150
+ ## 重构优势
151
+
152
+ ### 1. 提高组件复用性
153
+ - `ChatRoot` 现在是一个纯展示组件,可以在任何地方使用
154
+ - `bridge` 和 `tt` 的创建和配置由父组件控制,更加灵活
155
+ - 父组件可以自定义国际化内容,支持不同语言环境
156
+
157
+ ### 2. 简化路由结构
158
+ - 减少了不必要的路由层级
159
+ - 将聊天功能直接集成到消息页面中,符合业务逻辑
160
+
161
+ ### 3. 更好的关注点分离
162
+ - `ChatRoot` 及其子组件只关注 UI 展示
163
+ - 业务逻辑(store、api、bridge)在页面层管理
164
+ - 国际化配置在页面层统一管理
165
+ - 更容易测试和维护
166
+
167
+ ### 4. 减少样板代码
168
+ - 不需要为聊天功能创建单独的页面
169
+ - 不需要为页面创建单独的 i18n 配置
170
+ - 子组件不需要重复调用 `useI18nInterface`
171
+
172
+ ### 5. 提升性能
173
+ - 减少了 hook 调用次数(多个子组件共享同一个 `tt` 对象)
174
+ - 避免了重复的国际化配置解析
175
+
176
+ ## 使用示例
177
+
178
+ ### 基本用法
179
+
180
+ 如果需要在其他地方使用 `ChatRoot`:
181
+
182
+ ```typescript
183
+ import { useFactory } from '@brain-toolkit/react-kit';
184
+ import { chatMessageI18n } from '@config/i18n/chatMessageI18n';
185
+ import {
186
+ ChatMessageStore,
187
+ ChatSenderStrategy,
188
+ SendFailureStrategy
189
+ } from '@qlover/corekit-bridge';
190
+ import { useState } from 'react';
191
+ import { logger } from '@/core/globals';
192
+ import { useI18nInterface } from '@/uikit/hooks/useI18nInterface';
193
+ import { ChatMessageBridge } from '@/uikit/components/chatMessage/ChatMessageBridge';
194
+ import { ChatRoot } from '@/uikit/components/chatMessage/ChatRoot';
195
+ import { MessageApi } from '@/uikit/components/chatMessage/MessageApi';
196
+
197
+ function MyCustomChatPage() {
198
+ // 获取国际化对象
199
+ const tt = useI18nInterface(chatMessageI18n);
200
+
201
+ const messagesStore = useFactory(ChatMessageStore<string>);
202
+ const messageApi = useFactory(MessageApi, messagesStore);
203
+
204
+ const [bridge] = useState(() => {
205
+ return new ChatMessageBridge<string>(messagesStore, {
206
+ gateway: messageApi,
207
+ logger: logger,
208
+ senderName: 'MyCustomSender',
209
+ gatewayOptions: {
210
+ stream: true,
211
+ // 可以自定义其他选项
212
+ }
213
+ }).use(new ChatSenderStrategy(SendFailureStrategy.KEEP_FAILED, logger));
214
+ });
215
+
216
+ return (
217
+ <div>
218
+ <h1>My Custom Chat</h1>
219
+ <ChatRoot bridge={bridge} tt={tt} />
220
+ </div>
221
+ );
222
+ }
223
+ ```
224
+
225
+ ### 自定义国际化
226
+
227
+ 如果需要使用自定义的国际化配置:
228
+
229
+ ```typescript
230
+ import { useState } from 'react';
231
+ import type { ChatMessageI18nInterface } from '@config/i18n/chatMessageI18n';
232
+
233
+ // 自定义的国际化对象
234
+ const customI18n: ChatMessageI18nInterface = {
235
+ title: 'custom.chat.title',
236
+ empty: 'custom.chat.empty',
237
+ start: 'custom.chat.start',
238
+ // ... 其他配置
239
+ };
240
+
241
+ function MyCustomChatPage() {
242
+ const tt = useI18nInterface(customI18n);
243
+ // ... 其他逻辑
244
+
245
+ return <ChatRoot bridge={bridge} tt={tt} />;
246
+ }
247
+ ```
248
+
249
+ ## 注意事项
250
+
251
+ 1. `ChatRoot` 组件需要通过 props 接收两个必需参数:
252
+ - `bridge`: `ChatMessageBridge` 实例
253
+ - `tt`: `ChatMessageI18nInterface` 国际化对象
254
+
255
+ 2. `bridge` 的创建和配置应该在父组件中完成
256
+
257
+ 3. 确保 `bridge` 使用 `useState` 创建,避免重复初始化
258
+
259
+ 4. 国际化对象 `tt` 应该在父组件使用 `useI18nInterface` 获取,然后传递给 `ChatRoot`
260
+
261
+ 5. `ChatRoot` 依赖的所有子组件(`MessagesList`、`FocusBar`、`MessageItem`)都通过 props 接收 `bridge` 和 `tt`
262
+
263
+ 6. 所有子组件都不再自己调用 `useI18nInterface`,而是使用父组件传递的 `tt`
264
+
265
+ ## 相关文档
266
+
267
+ - [ChatMessage 组件文档](./chat-message-component.md)
268
+ - [MessagePage 简化说明](./message-page-简化说明.md)
269
+ - [开发指南](./development-guide.md)
270
+
@@ -0,0 +1,172 @@
1
+ # MessageBaseList 组件文档
2
+
3
+ ## 📋 组件概述
4
+
5
+ `MessageBaseList` 是一个简单的单向消息组件,用于测试消息网关(Gateway)功能。用户发送消息后,等待网关响应并显示结果。
6
+
7
+ ## ✨ 功能特性
8
+
9
+ - ✅ 发送消息到网关
10
+ - ✅ 实时显示消息状态(发送中、成功、失败)
11
+ - ✅ 美观的聊天界面样式
12
+ - ✅ 完整的国际化支持(中英文)
13
+ - ✅ 错误处理和重试机制
14
+ - ✅ 响应式设计
15
+
16
+ ## 🎨 界面特点
17
+
18
+ ### 消息显示
19
+
20
+ - **用户消息**:蓝色气泡,右对齐
21
+ - **网关响应**:
22
+ - **处理中**:灰色背景,带动画加载点
23
+ - **成功**:绿色背景,显示响应结果
24
+ - **失败**:红色背景,显示错误信息
25
+
26
+ ### 空状态
27
+
28
+ 当没有消息时,显示友好的提示文本,引导用户发送第一条消息。
29
+
30
+ ## 🔧 使用方式
31
+
32
+ ### 在页面中使用
33
+
34
+ ```tsx
35
+ import { MessageBaseList } from '@/uikit/components/MessageBaseList';
36
+
37
+ export default function MessagePage() {
38
+ return (
39
+ <div className="min-h-screen bg-primary py-8 px-4 sm:px-6 lg:px-8">
40
+ <MessageBaseList />
41
+ </div>
42
+ );
43
+ }
44
+ ```
45
+
46
+ ## 🌐 国际化配置
47
+
48
+ ### 文件结构
49
+
50
+ - **标识符定义**:`config/Identifier/components/component.messageBaseList.ts`
51
+ - **i18n 配置**:`config/i18n/messageBaseListI18n.ts`
52
+
53
+ ### 支持的文本
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 |
66
+
67
+ ## 🧪 测试功能
68
+
69
+ ### 模拟网关行为
70
+
71
+ 组件内置了 `MessageBaseApi` 类,模拟真实的网关行为:
72
+
73
+ - **正常响应**:200-1000ms 延迟,返回确认消息
74
+ - **触发错误**:
75
+ - 发送包含 "error" 或 "Failed" 的消息
76
+ - 随机网络错误(延迟能被 5 整除时)
77
+
78
+ ### 测试建议
79
+
80
+ ```
81
+ # 正常消息
82
+ Hello World
83
+
84
+ # 触发错误
85
+ error
86
+ Failed
87
+ test error message
88
+ ```
89
+
90
+ ## 📦 依赖的核心功能
91
+
92
+ ### @qlover/corekit-bridge
93
+
94
+ - `MessagesStore` - 消息状态管理
95
+ - `MessageSender` - 消息发送器
96
+ - `SenderStrategyPlugin` - 发送策略插件
97
+ - `SendFailureStrategy.KEEP_FAILED` - 保留失败消息的策略
98
+
99
+ ### 功能特点
100
+
101
+ 1. **自动状态管理**:消息的加载、成功、失败状态自动更新
102
+ 2. **失败保留**:失败的消息会保留在列表中,方便查看错误
103
+ 3. **防重复发送**:发送中时禁用输入和按钮
104
+
105
+ ## 🎯 样式系统
106
+
107
+ ### Tailwind CSS 类
108
+
109
+ 组件使用了项目的主题系统:
110
+
111
+ - `bg-primary` - 主背景色
112
+ - `bg-secondary` - 次级背景色
113
+ - `bg-base` - 基础背景色
114
+ - `text-text` - 主文本色
115
+ - `text-text-secondary` - 次级文本色
116
+ - `border-primary` - 主边框色
117
+
118
+ ### 响应式设计
119
+
120
+ - 消息最大宽度:70%(适应不同屏幕)
121
+ - 消息列表最大高度:96(约 384px)
122
+ - 消息列表最小高度:64(约 256px)
123
+ - 自动滚动:overflow-y-auto
124
+
125
+ ## 💡 使用场景
126
+
127
+ 1. **开发调试**:测试消息网关功能
128
+ 2. **演示展示**:展示消息发送和响应流程
129
+ 3. **集成测试**:验证消息系统集成是否正常
130
+ 4. **用户培训**:教学和培训用途
131
+
132
+ ## 🔄 状态流转
133
+
134
+ ```
135
+ 用户输入消息
136
+
137
+ 点击发送 / 回车
138
+
139
+ messagesSender.send()
140
+
141
+ 消息状态: loading = true
142
+
143
+ 调用 MessageBaseApi.sendMessage()
144
+
145
+ [成功] → status: SENT, result: 响应内容
146
+ [失败] → status: FAILED, error: 错误信息
147
+
148
+ UI 自动更新显示
149
+ ```
150
+
151
+ ## 📝 注意事项
152
+
153
+ 1. **清空输入**:发送成功后自动清空输入框
154
+ 2. **禁用控制**:发送中时禁用输入和发送按钮
155
+ 3. **错误处理**:使用 `(message as any).error` 访问错误信息(类型安全)
156
+ 4. **样式兼容**:使用 `wrap-break-word` 替代 `break-words`
157
+
158
+ ## 🚀 未来扩展
159
+
160
+ 可能的功能扩展方向:
161
+
162
+ - [ ] 支持图片、文件发送
163
+ - [ ] 支持消息编辑和删除
164
+ - [ ] 支持消息搜索
165
+ - [ ] 支持消息导出
166
+ - [ ] 支持自定义网关 API
167
+ - [ ] 支持 WebSocket 实时通信
168
+
169
+ ## 🎉 总结
170
+
171
+ `MessageBaseList` 是一个功能完整、样式美观的消息组件,完全支持国际化,适合用于测试和展示消息网关功能。
172
+
@@ -7,10 +7,7 @@ import unusedImports from 'eslint-plugin-unused-imports';
7
7
  import qloverEslint from '@qlover/eslint-plugin';
8
8
  import tseslint from 'typescript-eslint';
9
9
  import globals from 'globals';
10
- import {
11
- disableGlobals,
12
- restrictSpecificGlobals
13
- } from './makes/eslint-utils.mjs';
10
+ import { restrictSpecificGlobals } from './makes/eslint-utils.mjs';
14
11
 
15
12
  const __filename = fileURLToPath(import.meta.url);
16
13
  const __dirname = dirname(__filename);
@@ -186,10 +183,14 @@ const eslintConfig = [
186
183
  'prettier/prettier': [
187
184
  'error',
188
185
  {
189
- semi: true,
190
186
  singleQuote: true,
191
187
  trailingComma: 'none',
192
188
  endOfLine: 'lf'
189
+ },
190
+ {
191
+ // 仅用于单独部署时对 eslint prettier 插件自动查找 prettierrc 时报错
192
+ // 注意: vscode 等编辑器会失效, 作为单独项目开发时可以去掉
193
+ usePrettierrc: false
193
194
  }
194
195
  ],
195
196
  // 默认禁用 export default
@@ -32,7 +32,7 @@
32
32
  "dev:force": "vite --mode localhost --force",
33
33
  "dev:staging": "vite --mode staging",
34
34
  "dev:prod": "vite --mode production",
35
- "build": "npm run lint && vite build",
35
+ "build": "vite build",
36
36
  "build:staging": "npm run lint && vite build --mode staging",
37
37
  "build:prod": "npm run lint && vite build --mode production",
38
38
  "build:analyze": "vite build --mode production && start dist/stats.html",
@@ -29,25 +29,25 @@ export default defineConfig({
29
29
  baseURL: 'http://localhost:3200',
30
30
 
31
31
  /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
32
- trace: 'on-first-retry',
32
+ trace: 'on-first-retry'
33
33
  },
34
34
 
35
35
  /* Configure projects for major browsers */
36
36
  projects: [
37
37
  {
38
38
  name: 'chromium',
39
- use: { ...devices['Desktop Chrome'] },
39
+ use: { ...devices['Desktop Chrome'] }
40
40
  },
41
41
 
42
42
  {
43
43
  name: 'firefox',
44
- use: { ...devices['Desktop Firefox'] },
44
+ use: { ...devices['Desktop Firefox'] }
45
45
  },
46
46
 
47
47
  {
48
48
  name: 'webkit',
49
- use: { ...devices['Desktop Safari'] },
50
- },
49
+ use: { ...devices['Desktop Safari'] }
50
+ }
51
51
 
52
52
  /* Test against mobile viewports. */
53
53
  // {
@@ -68,7 +68,7 @@ export default defineConfig({
68
68
  // name: 'Google Chrome',
69
69
  // use: { ...devices['Desktop Chrome'], channel: 'chrome' },
70
70
  // },
71
- ],
71
+ ]
72
72
 
73
73
  /* Run your local dev server before starting the tests */
74
74
  // webServer: {
@@ -188,5 +188,48 @@
188
188
  "page_request:trigger_abort": "Trigger Abort Request",
189
189
  "page_request:stop_abort": "Stop Abort Request",
190
190
  "page_request:trigger_api_catch": "Trigger API Catch Result",
191
- "page_request:stop_api_catch": "Stop API Catch Result"
191
+ "page_request:stop_api_catch": "Stop API Catch Result",
192
+ "page_message:title": "Message Test",
193
+ "page_message:description": "Message gateway test page",
194
+ "page_message:keywords": "Message, Gateway, Test",
195
+ "page_message:search_placeholder": "Search message content",
196
+ "page_message:mark_read": "Mark as Read",
197
+ "page_message:mark_unread": "Mark as Unread",
198
+ "page_message:delete": "Delete",
199
+ "page_message:delete_selected": "Delete Selected",
200
+ "page_message:refresh": "Refresh",
201
+ "page_message:loading": "Loading...",
202
+ "page_message:empty": "No messages found",
203
+ "page_message:column_title": "Title",
204
+ "page_message:column_content": "Content",
205
+ "page_message:column_status": "Status",
206
+ "page_message:column_time": "Time",
207
+ "page_message:column_actions": "Actions",
208
+ "page_message:status_read": "Read",
209
+ "page_message:status_unread": "Unread",
210
+ "page_message:delete_confirm_title": "Confirm Delete",
211
+ "page_message:delete_confirm_content": "Are you sure you want to delete the selected messages?",
212
+ "page_message:delete_success": "Deleted successfully",
213
+ "page_message:mark_success": "Marked successfully",
214
+ "component_message_base_list:title": "Message Gateway Test",
215
+ "component_message_base_list:description": "Send messages and wait for gateway response",
216
+ "component_message_base_list:no_messages": "No messages yet",
217
+ "component_message_base_list:get_started": "Send your first message to get started",
218
+ "component_message_base_list:user": "You",
219
+ "component_message_base_list:gateway": "Gateway",
220
+ "component_message_base_list:processing": "Processing...",
221
+ "component_message_base_list:gateway_failed": "Gateway (Failed)",
222
+ "component_message_base_list:send_failed": "Failed to send message",
223
+ "component_message_base_list:gateway_response": "Gateway Response",
224
+ "component_message_base_list:input_placeholder": "Type your message here...",
225
+ "component_message_base_list:send_button": "Send",
226
+ "component_message_base_list:error_tip": "Tip: Try sending \"error\" or \"Failed\" to test error handling",
227
+ "component_chat:send": "Send",
228
+ "component_chat:stop": "Stop",
229
+ "component_chat:loading": "Loading...",
230
+ "component_chat:input_placeholder": "Type a message... (Ctrl+Enter to send)",
231
+ "component_chat:empty": "No messages yet",
232
+ "component_chat:start": "Start a conversation",
233
+ "component_chat:retry": "Retry",
234
+ "component_chat:duration": "Duration"
192
235
  }
@@ -188,5 +188,48 @@
188
188
  "page_request:trigger_abort": "触发中止请求",
189
189
  "page_request:stop_abort": "停止中止请求",
190
190
  "page_request:trigger_api_catch": "触发 API 捕获结果",
191
- "page_request:stop_api_catch": "停止 API 捕获结果"
191
+ "page_request:stop_api_catch": "停止 API 捕获结果",
192
+ "page_message:title": "消息测试",
193
+ "page_message:description": "消息网关测试页面",
194
+ "page_message:keywords": "消息, 网关, 测试",
195
+ "page_message:search_placeholder": "搜索消息内容",
196
+ "page_message:mark_read": "标记为已读",
197
+ "page_message:mark_unread": "标记为未读",
198
+ "page_message:delete": "删除",
199
+ "page_message:delete_selected": "删除选中",
200
+ "page_message:refresh": "刷新",
201
+ "page_message:loading": "加载中...",
202
+ "page_message:empty": "暂无消息",
203
+ "page_message:column_title": "标题",
204
+ "page_message:column_content": "内容",
205
+ "page_message:column_status": "状态",
206
+ "page_message:column_time": "时间",
207
+ "page_message:column_actions": "操作",
208
+ "page_message:status_read": "已读",
209
+ "page_message:status_unread": "未读",
210
+ "page_message:delete_confirm_title": "确认删除",
211
+ "page_message:delete_confirm_content": "确定要删除选中的消息吗?",
212
+ "page_message:delete_success": "删除成功",
213
+ "page_message:mark_success": "标记成功",
214
+ "component_message_base_list:title": "消息网关测试",
215
+ "component_message_base_list:description": "发送消息并等待网关响应",
216
+ "component_message_base_list:no_messages": "暂无消息",
217
+ "component_message_base_list:get_started": "发送第一条消息开始使用",
218
+ "component_message_base_list:user": "你",
219
+ "component_message_base_list:gateway": "网关",
220
+ "component_message_base_list:processing": "处理中...",
221
+ "component_message_base_list:gateway_failed": "网关(失败)",
222
+ "component_message_base_list:send_failed": "发送消息失败",
223
+ "component_message_base_list:gateway_response": "网关响应",
224
+ "component_message_base_list:input_placeholder": "在此输入您的消息...",
225
+ "component_message_base_list:send_button": "发送",
226
+ "component_message_base_list:error_tip": "提示:尝试发送 \"error\" 或 \"Failed\" 来测试错误处理",
227
+ "component_chat:send": "发送",
228
+ "component_chat:stop": "停止",
229
+ "component_chat:loading": "加载中...",
230
+ "component_chat:input_placeholder": "输入消息... (Ctrl+Enter 发送)",
231
+ "component_chat:empty": "暂无对话",
232
+ "component_chat:start": "开始对话",
233
+ "component_chat:retry": "重试",
234
+ "component_chat:duration": "耗时"
192
235
  }