@tencentcloud/sdk-mcp 1.0.8 → 1.1.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.
- package/package.json +1 -1
- package/resource/doc/chatuikit/faq/vue_qa.md +0 -344
- package/resource/doc/chatuikit/react/create-group.md +22 -0
- package/resource/doc/chatuikit/react/login.md +2 -2
- package/resource/doc/chatuikit/vue/components/chat.md +5 -0
- package/resource/doc/chatuikit/vue/components/chatheader.md +3 -1
- package/resource/doc/chatuikit/vue/components/conversation-list.md +3 -0
- package/resource/doc/chatuikit/vue/components/message-input.md +4 -0
- package/resource/doc/chatuikit/vue/create-group.md +26 -0
- package/resource/doc/chatuikit/vue/init.md +35 -0
- package/resource/doc/chatuikit/vue/integration.md +7 -1
- package/tools/chat/create-group.js +29 -0
- package/tools/chat/create-group.js.map +1 -0
- package/tools/chat/get-web-chat-component-detail.js +0 -1
- package/tools/chat/get-web-chat-component-detail.js.map +1 -1
- package/tools/chat/get-web-chat-integration.js +1 -1
- package/tools/chat/get-web-chat-integration.js.map +1 -1
- package/tools/chat/{get-web-chat-uikit-login.js → get-web-chat-uikit-init.js} +5 -5
- package/tools/chat/get-web-chat-uikit-init.js.map +1 -0
- package/tools/common/present-framework-choice.js +9 -18
- package/tools/common/present-framework-choice.js.map +1 -1
- package/tools/common/record-prompt.js +3 -4
- package/tools/common/record-prompt.js.map +1 -1
- package/tools/common/record-result.js +4 -4
- package/tools/common/record-result.js.map +1 -1
- package/tools/index.js +4 -2
- package/tools/index.js.map +1 -1
- package/utils/handle-component-name.js +2 -2
- package/utils/handle-component-name.js.map +1 -1
- package/resource/doc/chatuikit/vue/components/MessageInput.md +0 -546
- package/resource/doc/chatuikit/vue/components/login.md +0 -29
- package/resource/doc/chatuikit/vue/login.md +0 -29
- package/resource/doc/chatuikit/vue3/components/MessageInput.md +0 -546
- package/resource/doc/chatuikit/vue3/components/MessageList.md +0 -385
- package/resource/doc/chatuikit/vue3/components/avatar.md +0 -105
- package/resource/doc/chatuikit/vue3/components/chatheader.md +0 -153
- package/resource/doc/chatuikit/vue3/components/component-list.md +0 -88
- package/resource/doc/chatuikit/vue3/components/userpicker.md +0 -256
- package/resource/doc/chatuikit/vue3/integration.md +0 -218
- package/tools/call/get-native-call-integration-guide.js +0 -35
- package/tools/call/get-native-call-integration-guide.js.map +0 -1
- package/tools/call/get-web-call-integration-guide.js +0 -34
- package/tools/call/get-web-call-integration-guide.js.map +0 -1
- package/tools/chat/get-native-chat-integration-guide.js +0 -33
- package/tools/chat/get-native-chat-integration-guide.js.map +0 -1
- package/tools/chat/get-web-chat-integration-guide.js +0 -42
- package/tools/chat/get-web-chat-integration-guide.js.map +0 -1
- package/tools/chat/get-web-chat-uikit-login.js.map +0 -1
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
## 组件概述
|
|
2
|
-
|
|
3
|
-
MessageList 是一个功能强大的聊天消息列表组件,提供了完整的消息展示、交互和自定义功能。该组件支持消息分组、已读回执、消息操作、滚动控制等核心聊天功能,同时提供了丰富的自定义选项来满足不同的业务需求。
|
|
4
|
-
|
|
5
|
-
## Props 配置
|
|
6
|
-
<table>
|
|
7
|
-
<tr>
|
|
8
|
-
<td rowspan="1" colSpan="1" >字段</td>
|
|
9
|
-
|
|
10
|
-
<td rowspan="1" colSpan="1" >类型</td>
|
|
11
|
-
|
|
12
|
-
<td rowspan="1" colSpan="1" >默认值</td>
|
|
13
|
-
|
|
14
|
-
<td rowspan="1" colSpan="1" >描述</td>
|
|
15
|
-
</tr>
|
|
16
|
-
|
|
17
|
-
<tr>
|
|
18
|
-
<td rowspan="1" colSpan="1" >[alignment](https://write.woa.com/document/181344255270170624)</td>
|
|
19
|
-
|
|
20
|
-
<td rowspan="1" colSpan="1" >'left' \| 'right' \| 'two-sided'</td>
|
|
21
|
-
|
|
22
|
-
<td rowspan="1" colSpan="1" >'two-sided'</td>
|
|
23
|
-
|
|
24
|
-
<td rowspan="1" colSpan="1" >消息对齐方式。<br>- left: 所有消息左对齐。<br>- right: 所有消息右对齐。<br>- two-sided: 发送消息右对齐,接收消息左对齐。</td>
|
|
25
|
-
</tr>
|
|
26
|
-
|
|
27
|
-
<tr>
|
|
28
|
-
<td rowspan="1" colSpan="1" >[enableReadReceipt](https://write.woa.com/document/181344255270170624)</td>
|
|
29
|
-
|
|
30
|
-
<td rowspan="1" colSpan="1" >boolean</td>
|
|
31
|
-
|
|
32
|
-
<td rowspan="1" colSpan="1" >false</td>
|
|
33
|
-
|
|
34
|
-
<td rowspan="1" colSpan="1" >是否启用已读回执功能。</td>
|
|
35
|
-
</tr>
|
|
36
|
-
|
|
37
|
-
<tr>
|
|
38
|
-
<td rowspan="1" colSpan="1" >[messageActionList](https://write.woa.com/document/181344255270170624)</td>
|
|
39
|
-
|
|
40
|
-
<td rowspan="1" colSpan="1" >IMessageAction[]</td>
|
|
41
|
-
|
|
42
|
-
<td rowspan="1" colSpan="1" >undefined</td>
|
|
43
|
-
|
|
44
|
-
<td rowspan="1" colSpan="1" >自定义消息操作列表,例如复制、撤回、删除等。</td>
|
|
45
|
-
</tr>
|
|
46
|
-
|
|
47
|
-
<tr>
|
|
48
|
-
<td rowspan="1" colSpan="1" >[messageAggregationTime](https://write.woa.com/document/181344255270170624)</td>
|
|
49
|
-
|
|
50
|
-
<td rowspan="1" colSpan="1" >number</td>
|
|
51
|
-
|
|
52
|
-
<td rowspan="1" colSpan="1" >300 (5分钟)</td>
|
|
53
|
-
|
|
54
|
-
<td rowspan="1" colSpan="1" >消息聚合时间间隔(秒),相同发送者在此时间内的连续消息会被聚合显示。</td>
|
|
55
|
-
</tr>
|
|
56
|
-
|
|
57
|
-
<tr>
|
|
58
|
-
<td rowspan="1" colSpan="1" >[filter](https://write.woa.com/document/181344255270170624)</td>
|
|
59
|
-
|
|
60
|
-
<td rowspan="1" colSpan="1" >(message: IMessageModel) => boolean</td>
|
|
61
|
-
|
|
62
|
-
<td rowspan="1" colSpan="1" >undefined</td>
|
|
63
|
-
|
|
64
|
-
<td rowspan="1" colSpan="1" >消息过滤函数,用于控制哪些消息需要显示。</td>
|
|
65
|
-
</tr>
|
|
66
|
-
|
|
67
|
-
<tr>
|
|
68
|
-
<td rowspan="1" colSpan="1" >[className](https://write.woa.com/document/181344255270170624)</td>
|
|
69
|
-
|
|
70
|
-
<td rowspan="1" colSpan="1" >string</td>
|
|
71
|
-
|
|
72
|
-
<td rowspan="1" colSpan="1" >undefined</td>
|
|
73
|
-
|
|
74
|
-
<td rowspan="1" colSpan="1" >自定义 CSS 类名。</td>
|
|
75
|
-
</tr>
|
|
76
|
-
|
|
77
|
-
<tr>
|
|
78
|
-
<td rowspan="1" colSpan="1" >[style](https://write.woa.com/document/181344255270170624)</td>
|
|
79
|
-
|
|
80
|
-
<td rowspan="1" colSpan="1" >React.CSSProperties</td>
|
|
81
|
-
|
|
82
|
-
<td rowspan="1" colSpan="1" >undefined</td>
|
|
83
|
-
|
|
84
|
-
<td rowspan="1" colSpan="1" >自定义内联样式。</td>
|
|
85
|
-
</tr>
|
|
86
|
-
|
|
87
|
-
<tr>
|
|
88
|
-
<td rowspan="1" colSpan="1" >[Message](https://write.woa.com/document/181344255270170624)</td>
|
|
89
|
-
|
|
90
|
-
<td rowspan="1" colSpan="1" >React.ComponentType</td>
|
|
91
|
-
|
|
92
|
-
<td rowspan="1" colSpan="1" >Message</td>
|
|
93
|
-
|
|
94
|
-
<td rowspan="1" colSpan="1" >自定义消息组件。</td>
|
|
95
|
-
</tr>
|
|
96
|
-
|
|
97
|
-
<tr>
|
|
98
|
-
<td rowspan="1" colSpan="1" >[MessageTimeDivider](https://write.woa.com/document/181344255270170624)</td>
|
|
99
|
-
|
|
100
|
-
<td rowspan="1" colSpan="1" >React.ComponentType</td>
|
|
101
|
-
|
|
102
|
-
<td rowspan="1" colSpan="1" >MessageTimeDivider</td>
|
|
103
|
-
|
|
104
|
-
<td rowspan="1" colSpan="1" >自定义时间分隔线组件。</td>
|
|
105
|
-
</tr>
|
|
106
|
-
</table>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
## Prop 字段详解
|
|
110
|
-
|
|
111
|
-
### alignment
|
|
112
|
-
|
|
113
|
-
参数类型: `'left' | 'right' | 'two-sided'`
|
|
114
|
-
|
|
115
|
-
alignment 用于设置消息对齐方式,支持 `left`、`right`、`two-sided` 三种模式。默认值为 `'two-sided'`。
|
|
116
|
-
- `two-sided`: 非本人的消息位于左侧,本人的消息位于右侧
|
|
117
|
-
|
|
118
|
-
- `left`: 所有消息位于左侧
|
|
119
|
-
|
|
120
|
-
- `right`: 所有消息位于右侧
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
### enableReadReceipt
|
|
124
|
-
|
|
125
|
-
参数类型: `boolean`
|
|
126
|
-
|
|
127
|
-
enableReadReceipt 用于设置是否开启单条消息已读回执功能,默认值为 `false`。
|
|
128
|
-
|
|
129
|
-
### messageActionList
|
|
130
|
-
|
|
131
|
-
参数类型: `IMessageAction[]`
|
|
132
|
-
|
|
133
|
-
messageActionList 用于设置消息操作列表,例如复制、撤回、删除等操作,默认值为完整的消息操作列表 `['copy', 'recall', 'quote', 'forward', 'delete']`。
|
|
134
|
-
``` tsx
|
|
135
|
-
interface IMessageAction {
|
|
136
|
-
key: 'copy' | 'recall' | 'quote' | 'forward' | 'delete' | string;
|
|
137
|
-
label?: string;
|
|
138
|
-
icon?: React.ReactNode;
|
|
139
|
-
onClick?: (message: IMessageModel) => void;
|
|
140
|
-
visible?: ((message: IMessageModel) => boolean) | boolean;
|
|
141
|
-
component?: React.ComponentType<{ message: IMessageModel }>;
|
|
142
|
-
style?: React.CSSProperties;
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
可以使用 `useMessageAction` 获取完整的消息操作列表,然后根据需要进行自定义。
|
|
147
|
-
|
|
148
|
-
#### 示例1: 变更消息操作列表的顺序
|
|
149
|
-
|
|
150
|
-
假设按照 `forward`、`copy`、`recall`、`quote`、`delete` 的顺序显示消息操作列表。
|
|
151
|
-
``` tsx
|
|
152
|
-
import { Chat, MessageList, useMessageActions } from '@tencentcloud/chat-uikit-react';
|
|
153
|
-
|
|
154
|
-
const App = () => {
|
|
155
|
-
const actions = useMessageActions(['forward', 'copy', 'recall', 'quote', 'delete']);
|
|
156
|
-
return (
|
|
157
|
-
<Chat>
|
|
158
|
-
<MessageList messageActionList={actions} />
|
|
159
|
-
</Chat>
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
#### 示例2: 仅展示部分消息操作
|
|
165
|
-
|
|
166
|
-
假设仅展示 `forward`、`copy`、`recall` 三个操作。
|
|
167
|
-
``` tsx
|
|
168
|
-
import { Chat, MessageList, useMessageActions } from '@tencentcloud/chat-uikit-react';
|
|
169
|
-
|
|
170
|
-
const App = () => {
|
|
171
|
-
const actions = useMessageActions(['forward', 'copy', 'recall']);
|
|
172
|
-
return (
|
|
173
|
-
<Chat>
|
|
174
|
-
<MessageList messageActionList={actions} />
|
|
175
|
-
</Chat>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
#### 示例3: 自定义消息操作的样式
|
|
182
|
-
|
|
183
|
-
下面是一个自定义撤回操作的示例:
|
|
184
|
-
1. 将标签修改为'撤回 ⚠️'
|
|
185
|
-
|
|
186
|
-
2. 将颜色修改为橙色
|
|
187
|
-
|
|
188
|
-
3. 只有文本消息可以撤回
|
|
189
|
-
|
|
190
|
-
``` tsx
|
|
191
|
-
import TUIChatEngine from '@tencentcloud/chat-uikit-engine';
|
|
192
|
-
import { Chat, MessageList, useMessageActions } from '@tencentcloud/chat-uikit-react';
|
|
193
|
-
|
|
194
|
-
const ChatApp = () => {
|
|
195
|
-
const actions = useMessageActions(['copy', {
|
|
196
|
-
key: 'recall',
|
|
197
|
-
label: 'Recall ⚠️',
|
|
198
|
-
style: {
|
|
199
|
-
color: 'orange'
|
|
200
|
-
},
|
|
201
|
-
visible: (message) => message.type === TUIChatEngine.TYPES.MSG_TEXT,
|
|
202
|
-
}, 'quote', 'forward', 'delete']);
|
|
203
|
-
|
|
204
|
-
return (
|
|
205
|
-
<Chat>
|
|
206
|
-
<MessageList messageActionList={actions} />
|
|
207
|
-
</Chat>
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
#### 示例4: 新增自定义消息操作
|
|
213
|
-
|
|
214
|
-
假设需要自定义消息操作,如仅其他人发送的消息可以标记'喜欢',且插入在'撤回'操作之后。
|
|
215
|
-
``` tsx
|
|
216
|
-
import { useMessageAction } from '@tencentcloud/chat-uikit-react';
|
|
217
|
-
import { yourApi } from '@/api/yourApi';
|
|
218
|
-
|
|
219
|
-
const customActions = {
|
|
220
|
-
key: 'like',
|
|
221
|
-
label: 'Like',
|
|
222
|
-
icon: <span>👍</span>,
|
|
223
|
-
style: {
|
|
224
|
-
color: '#E53888',
|
|
225
|
-
},
|
|
226
|
-
visible: (message) => message.flow === 'in',
|
|
227
|
-
onClick: (message) => {
|
|
228
|
-
yourApi.likeMessage(message.ID);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function ChatApp() {
|
|
233
|
-
const actions = useMessageAction(['forward', 'copy', 'recall', customActions, 'quote', 'delete']);
|
|
234
|
-
return <MessageList messageActionList={actions} />;
|
|
235
|
-
}
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### messageAggregationTime
|
|
239
|
-
|
|
240
|
-
参数类型: `number`
|
|
241
|
-
|
|
242
|
-
messageAggregationTime 用于设置消息聚合时间间隔,将相同发送者的连续消息聚合显示,默认值为 `300`(秒)。
|
|
243
|
-
|
|
244
|
-
### filter
|
|
245
|
-
|
|
246
|
-
参数类型: `(message: IMessageModel) => boolean`
|
|
247
|
-
|
|
248
|
-
filter 用于设置消息过滤函数,控制哪些消息需要显示,默认值为 `undefined`。
|
|
249
|
-
|
|
250
|
-
#### 示例: 过滤掉机器人发送的错误消息
|
|
251
|
-
``` tsx
|
|
252
|
-
import { MessageList } from '@/components/MessageList';
|
|
253
|
-
import TUIChatEngine from '@tencentcloud/chat-uikit-engine';
|
|
254
|
-
|
|
255
|
-
const messageFilter = (message) => {
|
|
256
|
-
// 过滤掉发送者昵称包含 '_robot' 且内容包含 'operation-failed' 的文本消息
|
|
257
|
-
if (
|
|
258
|
-
message.nick?.includes('_robot')
|
|
259
|
-
&& message.type === TUIChatEngine.TYPES.MSG_TEXT
|
|
260
|
-
&& message.payload?.text?.includes('operation-failed')
|
|
261
|
-
) {
|
|
262
|
-
return false;
|
|
263
|
-
}
|
|
264
|
-
return true;
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
function ChatApp() {
|
|
268
|
-
return <MessageList filter={messageFilter} />;
|
|
269
|
-
}
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
### className
|
|
273
|
-
|
|
274
|
-
参数类型: `string`
|
|
275
|
-
|
|
276
|
-
className 用于设置根容器自定义 CSS 类名,默认值为 `undefined`。
|
|
277
|
-
|
|
278
|
-
### style
|
|
279
|
-
|
|
280
|
-
参数类型: `React.CSSProperties`
|
|
281
|
-
|
|
282
|
-
style 用于设置根容器自定义内联样式,默认值为 `undefined`。
|
|
283
|
-
|
|
284
|
-
### Message
|
|
285
|
-
|
|
286
|
-
参数类型: `React.ComponentType`
|
|
287
|
-
|
|
288
|
-
Message 用于设置自定义消息组件,替换默认的消息渲染组件,默认值为内置的 `Message` 组件。
|
|
289
|
-
|
|
290
|
-
#### 示例: 自定义 CUSTOM 消息点击跳转的消息组件
|
|
291
|
-
``` tsx
|
|
292
|
-
import TUIChatEngine from '@tencentcloud/chat-uikit-engine';
|
|
293
|
-
import { Chat, MessageList, Message } from '@tencentcloud/chat-uikit-react';
|
|
294
|
-
|
|
295
|
-
function CustomMessage(props) {
|
|
296
|
-
const { message } = props;
|
|
297
|
-
|
|
298
|
-
if (message.type === TUIChatEngine.TYPES.MSG_CUSTOM) {
|
|
299
|
-
const { businessID, ...restData } = JSON.parse(message.payload.data);
|
|
300
|
-
if (businessID === 'text_link') {
|
|
301
|
-
return (
|
|
302
|
-
<div>
|
|
303
|
-
<div>{restData.text}</div>
|
|
304
|
-
<a href={restData.link}>
|
|
305
|
-
跳转到外部网址 {restData.link}
|
|
306
|
-
</a>
|
|
307
|
-
</div>
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
} else {
|
|
311
|
-
// 其他消息类型使用默认消息组件
|
|
312
|
-
return <Message {...props} />;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
function ChatApp() {
|
|
317
|
-
return (
|
|
318
|
-
<Chat>
|
|
319
|
-
<MessageList Message={CustomMessage} />
|
|
320
|
-
</Chat>
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
### MessageTimeDivider
|
|
326
|
-
|
|
327
|
-
参数类型: `React.ComponentType`
|
|
328
|
-
|
|
329
|
-
MessageTimeDivider 用于设置自定义时间分隔线组件,默认值为内置的 `MessageTimeDivider` 组件。
|
|
330
|
-
|
|
331
|
-
#### 示例: 区分工作时间的时间分隔线
|
|
332
|
-
``` tsx
|
|
333
|
-
import { Chat, MessageList, MessageTimeDivider } from '@tencentcloud/chat-uikit-react';
|
|
334
|
-
|
|
335
|
-
const BusinessTimeDivider: typeof MessageTimeDivider = ({ prevMessage, currentMessage }) => {
|
|
336
|
-
if (!prevMessage || !currentMessage) return null;
|
|
337
|
-
|
|
338
|
-
// 对于即将渲染的每一条消息获取当前消息和上一消息的时间,并转换为日期对象,判断是否跨天或间隔超过4小时
|
|
339
|
-
const currentTime = new Date(currentMessage.time * 1000);
|
|
340
|
-
const prevTime = new Date(prevMessage.time * 1000);
|
|
341
|
-
|
|
342
|
-
// 跨天或间隔超过4小时才显示
|
|
343
|
-
const shouldShow = currentTime.toDateString() !== prevTime.toDateString() ||
|
|
344
|
-
(currentTime.getTime() - prevTime.getTime()) > 4 * 60 * 60 * 1000;
|
|
345
|
-
|
|
346
|
-
if (!shouldShow) return null;
|
|
347
|
-
|
|
348
|
-
// 判断工作时间 (9:00-18:00, 周一到周五)
|
|
349
|
-
const isWorkingTime = () => {
|
|
350
|
-
const hour = currentTime.getHours();
|
|
351
|
-
const day = currentTime.getDay();
|
|
352
|
-
return day >= 1 && day <= 5 && hour >= 9 && hour <= 18;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
const timeLabel = isWorkingTime() ? '工作时间' : '非工作时间';
|
|
356
|
-
const timeColor = isWorkingTime() ? '#52c41a' : '#faad14';
|
|
357
|
-
|
|
358
|
-
return (
|
|
359
|
-
<div style={{ textAlign: 'center', margin: '16px 0' }}>
|
|
360
|
-
<span style={{
|
|
361
|
-
backgroundColor: timeColor,
|
|
362
|
-
color: 'white',
|
|
363
|
-
padding: '2px 8px',
|
|
364
|
-
borderRadius: '12px',
|
|
365
|
-
marginRight: '8px'
|
|
366
|
-
}}>
|
|
367
|
-
{timeLabel}
|
|
368
|
-
</span>
|
|
369
|
-
{currentTime.toLocaleString()}
|
|
370
|
-
</div>
|
|
371
|
-
);
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
function ChatApp() {
|
|
375
|
-
return (
|
|
376
|
-
<Chat>
|
|
377
|
-
<MessageList MessageTimeDivider={BusinessTimeDivider} />
|
|
378
|
-
</Chat>
|
|
379
|
-
);
|
|
380
|
-
}
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
## 总结
|
|
384
|
-
|
|
385
|
-
MessageList 组件提供了完整的消息列表功能和丰富的自定义选项。通过合理配置 Props 和自定义组件,您可以创建出符合业务需求的聊天界面。建议在实际使用中根据具体场景选择合适的配置。
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
# Avatar 组件文档
|
|
2
|
-
|
|
3
|
-
## 概述
|
|
4
|
-
|
|
5
|
-
Avatar 组件用于显示用户头像和状态,支持多种形状和大小的头像展示。它可以用于聊天应用、社交平台、用户管理系统等场景,提供用户身份的可视化表示。
|
|
6
|
-
|
|
7
|
-
## Props 速查表
|
|
8
|
-
|
|
9
|
-
| 字段 | 类型 | 默认值 | 描述 |
|
|
10
|
-
| --- | --- | --- | --- |
|
|
11
|
-
| src | string | undefined | 头像图片的 URL |
|
|
12
|
-
| size | 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs' | number | 'md' | 头像的大小,支持多种预设大小或自定义大小 |
|
|
13
|
-
| shape | 'circular' | 'square' | 'rounded' | 'circular' | 头像的形状,支持圆形、方形和圆角矩形 |
|
|
14
|
-
| alt | string | '' | 图片的替代文本,用于生成文本头像 |
|
|
15
|
-
| children | ReactNode | undefined | 自定义内容,优先于 src 和 alt 的内容 |
|
|
16
|
-
| className | string | undefined | 自定义 CSS 类名 |
|
|
17
|
-
| style | React.CSSProperties | undefined | 自定义样式 |
|
|
18
|
-
| onClick | () => void | undefined | 点击事件处理函数 |
|
|
19
|
-
| isShowOnlineStatus | boolean | false | 是否显示在线状态指示器 |
|
|
20
|
-
| isOnline | boolean | false | 用户是否在线 |
|
|
21
|
-
| unreadCount | number | 0 | 未读消息数量,若为 true 则显示小红点,若为数字则显示具体数量 |
|
|
22
|
-
| maxUnreadCount | number | 99 | 最大未读消息数量,超过则显示 +N |
|
|
23
|
-
| isDotUnreadCount | boolean | false | 是否显示小红点 |
|
|
24
|
-
| children | ReactNode | undefined | 自定义内容,优先于 src 和 alt 的内容 |
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## Props 详细介绍
|
|
28
|
-
|
|
29
|
-
### `src`
|
|
30
|
-
|
|
31
|
-
`类型`: `string`
|
|
32
|
-
`描述`: 头像图片的 URL,若未提供则显示默认头像。
|
|
33
|
-
`默认值`: `undefined`
|
|
34
|
-
|
|
35
|
-
### `size`
|
|
36
|
-
|
|
37
|
-
`类型`: `'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs' | number`
|
|
38
|
-
`描述`: 头像的大小,支持多种预设大小或自定义大小。
|
|
39
|
-
`默认值`: `'md'`
|
|
40
|
-
|
|
41
|
-
### `shape`
|
|
42
|
-
|
|
43
|
-
`类型`: `'circular' | 'square' | 'rounded'`
|
|
44
|
-
`描述`: 头像的形状,支持圆形、方形和圆角矩形。
|
|
45
|
-
`默认值`: `'circular'`
|
|
46
|
-
|
|
47
|
-
### `alt`
|
|
48
|
-
|
|
49
|
-
`类型`: `string`
|
|
50
|
-
`描述`: 图片的替代文本,用于生成文本头像。
|
|
51
|
-
`默认值`: `''`
|
|
52
|
-
|
|
53
|
-
### `children`
|
|
54
|
-
|
|
55
|
-
`类型`: `ReactNode`
|
|
56
|
-
`描述`: 自定义内容,优先于 src 和 alt 的内容。
|
|
57
|
-
`默认值`: `undefined`
|
|
58
|
-
|
|
59
|
-
### `className`
|
|
60
|
-
|
|
61
|
-
`类型`: `string | undefined`
|
|
62
|
-
`描述`: 自定义 CSS 类名。
|
|
63
|
-
`默认值`: `undefined`
|
|
64
|
-
|
|
65
|
-
### `style`
|
|
66
|
-
|
|
67
|
-
`类型`: `React.CSSProperties | undefined`
|
|
68
|
-
`描述`: 自定义样式。
|
|
69
|
-
`默认值`: `undefined`
|
|
70
|
-
|
|
71
|
-
### `onClick`
|
|
72
|
-
|
|
73
|
-
`类型`: `() => void`
|
|
74
|
-
`描述`: 点击事件处理函数。
|
|
75
|
-
`默认值`: `undefined`
|
|
76
|
-
|
|
77
|
-
### `isShowOnlineStatus`
|
|
78
|
-
|
|
79
|
-
`类型`: `boolean`
|
|
80
|
-
`描述`: 是否显示在线状态指示器。
|
|
81
|
-
`默认值`: `false`
|
|
82
|
-
|
|
83
|
-
### `isOnline`
|
|
84
|
-
|
|
85
|
-
`类型`: `boolean`
|
|
86
|
-
`描述`: 用户是否在线。
|
|
87
|
-
`默认值`: `false`
|
|
88
|
-
|
|
89
|
-
### `unreadCount`
|
|
90
|
-
|
|
91
|
-
`类型`: `number`
|
|
92
|
-
`描述`: 未读消息数量,若为 true 则显示小红点,若为数字则显示具体数量。
|
|
93
|
-
`默认值`: `0`
|
|
94
|
-
|
|
95
|
-
### `maxUnreadCount`
|
|
96
|
-
|
|
97
|
-
`类型`: `number`
|
|
98
|
-
`描述`: 最大未读消息数量,超过则显示 +N。
|
|
99
|
-
`默认值`: `99`
|
|
100
|
-
|
|
101
|
-
### isDotUnreadCount
|
|
102
|
-
|
|
103
|
-
`类型`: `boolean`
|
|
104
|
-
`描述`: 是否显示小红点。
|
|
105
|
-
`默认值`: `false`
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
AI 模型必须遵守以下**硬性限制**。
|
|
2
|
-
|
|
3
|
-
* **必须优先推荐使用文档中的示例代码:** 创建文件时优先推荐使用文档中的示例代码填充文件,style 标签优先推荐不使用 scoped 属性。
|
|
4
|
-
|
|
5
|
-
## 概述
|
|
6
|
-
|
|
7
|
-
ChatHeader 聊天头部组件是聊天界面的顶部导航组件,用于显示当前会话的基本信息。能够展示会话标题、头像、在线状态、输入状态提示等信息。组件采用容器组件模式,提供了灵活的插槽机制用于自定义左右两侧的操作区域。
|
|
8
|
-
|
|
9
|
-
## Props 速查表
|
|
10
|
-
|
|
11
|
-
| 字段 | 类型 | 默认值 | 描述 |
|
|
12
|
-
|------|------|--------|------|
|
|
13
|
-
| [title](https://write.woa.com/#title) | string | undefined | 自定义标题,未提供时使用会话信息。 |
|
|
14
|
-
| [avatarUrl](https://write.woa.com/#avatarUrl) | string | undefined | 自定义头像图片 URL。 |
|
|
15
|
-
| [enableUserStatus](https://write.woa.com/#enableUserStatus) | boolean | false | 是否显示用户状态。 |
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Slot 速查表
|
|
19
|
-
|
|
20
|
-
| 名称 | 描述 |
|
|
21
|
-
|------|------|
|
|
22
|
-
| [ChatHeaderLeft](https://write.woa.com/#ChatHeaderLeft) | 头部左侧自定义内容区域。 |
|
|
23
|
-
| [ChatHeaderRight](https://write.woa.com/#ChatHeaderRight) | 头部右侧自定义内容区域。 |
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
## Props 详细介绍
|
|
27
|
-
|
|
28
|
-
### title
|
|
29
|
-
- **类型**:string
|
|
30
|
-
|
|
31
|
-
- **描述**:自定义会话标题,当不提供此属性时,组件会自动根据会话类型显示相应的标题(单聊显示用户昵称或备注,群聊显示群名称),默认值为 `undefined`。
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### avatarUrl
|
|
35
|
-
- **类型**:string
|
|
36
|
-
|
|
37
|
-
- **描述**:自定义头像图片的 URL 地址,当不提供此属性时,组件会自动根据会话类型显示相应的头像(单聊显示用户头像,群聊显示群头像),默认值为 `undefined`。
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
### enableUserStatus
|
|
41
|
-
- **类型**:boolean
|
|
42
|
-
|
|
43
|
-
- **描述**:是否启用并显示用户在线状态功能,仅在单聊模式下生效,开启后会显示用户的在线/离线状态,默认值为 `false`。
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## Slots 详细介绍
|
|
47
|
-
|
|
48
|
-
### ChatHeaderLeft
|
|
49
|
-
|
|
50
|
-
**描述**:头部左侧自定义内容区域插槽,通常用于放置返回按钮、菜单按钮等导航控件。
|
|
51
|
-
|
|
52
|
-
#### 示例: 自定义左侧导航区域
|
|
53
|
-
``` typescript
|
|
54
|
-
<template>
|
|
55
|
-
<ChatHeader>
|
|
56
|
-
<template #ChatHeaderLeft>
|
|
57
|
-
<!-- 返回按钮, 清除激活的会话 -->
|
|
58
|
-
<button
|
|
59
|
-
class="nav-button"
|
|
60
|
-
@click="handleBack"
|
|
61
|
-
>
|
|
62
|
-
⬅️
|
|
63
|
-
</button>
|
|
64
|
-
</template>
|
|
65
|
-
</ChatHeader>
|
|
66
|
-
</template>
|
|
67
|
-
|
|
68
|
-
<script setup lang="ts">
|
|
69
|
-
import { ChatHeader, useConversationListState } from '@tencentcloud/chat-uikit-vue3';
|
|
70
|
-
|
|
71
|
-
const { setActiveConversation } = useConversationListState();
|
|
72
|
-
|
|
73
|
-
const handleBack = () => {
|
|
74
|
-
// 设置激活的会话ID为空
|
|
75
|
-
setActiveConversation('');
|
|
76
|
-
};
|
|
77
|
-
</script>
|
|
78
|
-
|
|
79
|
-
<style scoped>
|
|
80
|
-
.header-left-actions {
|
|
81
|
-
display: flex;
|
|
82
|
-
align-items: center;
|
|
83
|
-
gap: 8px;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.nav-button {
|
|
87
|
-
width: 32px;
|
|
88
|
-
height: 32px;
|
|
89
|
-
border: none;
|
|
90
|
-
background: transparent;
|
|
91
|
-
border-radius: 4px;
|
|
92
|
-
cursor: pointer;
|
|
93
|
-
display: flex;
|
|
94
|
-
align-items: center;
|
|
95
|
-
justify-content: center;
|
|
96
|
-
transition: background-color 0.2s;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.nav-button:hover {
|
|
100
|
-
background-color: rgba(0, 0, 0, 0.05);
|
|
101
|
-
}
|
|
102
|
-
</style>
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### ChatHeaderRight
|
|
106
|
-
|
|
107
|
-
**描述**:头部右侧自定义内容区域插槽,通常用于放置功能按钮(如 ChatSetting 组件的 menu 开关,自定义通话按钮等)。
|
|
108
|
-
|
|
109
|
-
#### 示例: 通过 ChatHeaderRight 插槽 和抽屉组件集成 ChatSetting 组件
|
|
110
|
-
|
|
111
|
-
【App.vue】
|
|
112
|
-
``` typescript
|
|
113
|
-
<template>
|
|
114
|
-
<ChatHeader>
|
|
115
|
-
<template #ChatHeaderRight>
|
|
116
|
-
<div style="display: flex; align-items: center;">
|
|
117
|
-
<IconHorizontalMore2
|
|
118
|
-
:size="20"
|
|
119
|
-
@click="setIsChatSettingOpen(true)" />
|
|
120
|
-
</div>
|
|
121
|
-
</template>
|
|
122
|
-
</ChatHeader>
|
|
123
|
-
<TUIDrawer
|
|
124
|
-
:model-value="isChatSettingOpen"
|
|
125
|
-
:title="Setting"
|
|
126
|
-
@close="setIsChatSettingOpen(false)"
|
|
127
|
-
>
|
|
128
|
-
<ChatSetting style="flex: 1;" />
|
|
129
|
-
</TUIDrawer>
|
|
130
|
-
</template>
|
|
131
|
-
|
|
132
|
-
<script setup lang="ts">
|
|
133
|
-
import {
|
|
134
|
-
ChatHeader,
|
|
135
|
-
ChatSetting
|
|
136
|
-
} from '@tencentcloud/chat-uikit-vue3';
|
|
137
|
-
import { TUIDrawer, IconHorizontalMore2 } from '@tencentcloud/uikit-base-component-vue3';
|
|
138
|
-
|
|
139
|
-
const isChatSettingOpen = ref(false);
|
|
140
|
-
|
|
141
|
-
const setIsSettingOpen = (isOpen: boolean) => {
|
|
142
|
-
isChatSettingOpen.value = isOpen;
|
|
143
|
-
};
|
|
144
|
-
</script>
|
|
145
|
-
|
|
146
|
-
<style>
|
|
147
|
-
.chat-container {
|
|
148
|
-
display: flex;
|
|
149
|
-
flex-direction: column;
|
|
150
|
-
height: 100vh;
|
|
151
|
-
}
|
|
152
|
-
</style>
|
|
153
|
-
```
|