@blueking/chat-x 0.0.51-beta.3 → 0.0.51-beta.4
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.
|
@@ -325,7 +325,7 @@ const handleSendMessage = async (
|
|
|
325
325
|
|
|
326
326
|
- 底部工具栏出现文件上传按钮(在快捷指令左侧)
|
|
327
327
|
- 支持**点击选择**、**拖拽上传**、**粘贴上传**(Ctrl+V)
|
|
328
|
-
- `onUpload`
|
|
328
|
+
- `onUpload` 一次选择传入**全部** `File[]`,返回同序的结果数组(也可对单文件返回单个对象);元素为 `{ download_url?: string; id?: string; status?: 'failed' | 'success' }`
|
|
329
329
|
- 文件自动去重(基于 `name + size + lastModified` 复合键),不会重复上传
|
|
330
330
|
- **上传中或存在失败附件时禁止发送**(点击、Enter、`triggerSendMessage` 均拦截)。失败附件需用户删除后才能再发;不要把附件 Pending 映射成 `MessageStatus.Pending`
|
|
331
331
|
- 发送成功后,`uploadFiles` 自动清空
|
|
@@ -333,7 +333,7 @@ const handleSendMessage = async (
|
|
|
333
333
|
**个数与大小校验(与 `FileUploadBtn` 分工)**:
|
|
334
334
|
|
|
335
335
|
- 列表最多保留 **`MAX_UPLOAD_FILES`(9)** 个待发送附件;已满时再次选择/拖入/粘贴文件会弹出 **bkui-vue `Message` 错误提示**(`formatUploadNotAddedMessage`),且不会继续入队。
|
|
336
|
-
- 在未满的前提下:空文件、单文件大小 **`>= MAX_UPLOAD_FILE_SIZE`(约 2.4MB
|
|
336
|
+
- 在未满的前提下:空文件、单文件大小 **`>= MAX_UPLOAD_FILE_SIZE`(约 2.4MB)** 会被跳过并弹出超大小/个数提示。与已有文件重复的项只去重、不弹这条误导文案。
|
|
337
337
|
- `FileUploadBtn` 仅在按钮层过滤**空文件与单文件超大**,把合法文件以数组形式 `upload` 上来;**个数上限与重复校验**在 `ChatInput` 的 `handleUpload` 中统一处理,避免与按钮层各弹一条提示。
|
|
338
338
|
|
|
339
339
|
**发送内容格式**(有文件时):
|
|
@@ -383,12 +383,12 @@ const handleSendMessage = async (
|
|
|
383
383
|
messageStatus.value = MessageStatus.Stop;
|
|
384
384
|
};
|
|
385
385
|
|
|
386
|
-
//
|
|
387
|
-
const handleUpload = async (
|
|
386
|
+
// 一次选择多个文件只回调一次,按文件顺序返回结果
|
|
387
|
+
const handleUpload = async (files: File[]) => {
|
|
388
388
|
const formData = new FormData();
|
|
389
|
-
formData.append('
|
|
389
|
+
files.forEach(file => formData.append('files', file));
|
|
390
390
|
const res = await fetch('/api/upload', { method: 'POST', body: formData });
|
|
391
|
-
return res.json(); //
|
|
391
|
+
return res.json(); // ChatInputUploadResult[]
|
|
392
392
|
};
|
|
393
393
|
</script>
|
|
394
394
|
```
|
|
@@ -605,7 +605,7 @@ const handleSendMessage = async (
|
|
|
605
605
|
| tippyOptions | `AITippyProps` | — | - | 透传给 FileUploadBtn 和 InputAttachment 的 tooltip 配置 |
|
|
606
606
|
| onSendMessage | `(content: UserMessage['content'], docSchema: TagSchema, options?: { interrupt?: Interrupt; payload?: InterruptResume }) => Promise<void>` | - | - | 发送消息回调,无文件时 content 为字符串,有文件时为数组;经 [ChatContainer](/components/setup/chat-container) 使用时,存在待回答 UserQuestion 会传入第三参数 `options` |
|
|
607
607
|
| onStopSending | `() => Promise<void>` | - | - | 停止发送回调,点击停止按钮时触发 |
|
|
608
|
-
| onUpload | `(
|
|
608
|
+
| onUpload | `(files: File[]) => Promise<ChatInputUploadResult \| ChatInputUploadResult[]>` | - | - | 文件上传回调(一次选择批量传入);上传中/失败附件会阻塞发送 |
|
|
609
609
|
|
|
610
610
|
### 默认占位符
|
|
611
611
|
|
|
@@ -758,11 +758,11 @@ type OnSendMessage = (
|
|
|
758
758
|
abortAICall();
|
|
759
759
|
};
|
|
760
760
|
|
|
761
|
-
const handleUpload = async (
|
|
761
|
+
const handleUpload = async (files: File[]) => {
|
|
762
762
|
const formData = new FormData();
|
|
763
|
-
formData.append('
|
|
763
|
+
files.forEach(file => formData.append('files', file));
|
|
764
764
|
const res = await fetch('/api/upload', { method: 'POST', body: formData });
|
|
765
|
-
return res.json();
|
|
765
|
+
return res.json();
|
|
766
766
|
};
|
|
767
767
|
</script>
|
|
768
768
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blueking/chat-x",
|
|
3
|
-
"version": "0.0.51-beta.
|
|
3
|
+
"version": "0.0.51-beta.4",
|
|
4
4
|
"description": "蓝鲸智云 AI Chat 组件库 —— 遵循 AG-UI,为 AI Agent 和人类开发者共同设计的对话 UI 组件库。",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"vitepress": "2.0.0-alpha.16",
|
|
80
80
|
"vitest": "^4.0.18",
|
|
81
81
|
"vue-tsc": "^3.1.4",
|
|
82
|
-
"@blueking/chat-helper": "0.0.12-beta.
|
|
82
|
+
"@blueking/chat-helper": "0.0.12-beta.30"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
|
85
85
|
"dev": "vite --config vite.config.ts",
|