fix: 修复 Chrome 90 智能体文档上传失败

- 复用兼容 UUID 生成逻辑,移除对 crypto.randomUUID 的依赖

- 补充旧浏览器缺失 randomUUID 时的上传回归测试
This commit is contained in:
2026-07-29 16:20:37 +08:00
parent 9c3badc55c
commit 19c7b60a65
4 changed files with 47 additions and 2 deletions

View File

@@ -32,6 +32,7 @@
"@easyflow/icons": "workspace:*",
"@easyflow/locales": "workspace:*",
"@easyflow/types": "workspace:*",
"@easyflow/utils": "workspace:*",
"@incremark/theme": "1.0.2",
"@incremark/vue": "1.0.2",
"@vueuse/core": "catalog:",

View File

@@ -2,6 +2,8 @@ import type { ChatDocumentAttachment } from './types';
import { computed, ref } from 'vue';
import { uuid } from '@easyflow/utils';
const MAX_DOCUMENTS = 3;
const MAX_TOTAL_BYTES = 30 * 1024 * 1024;
const MAX_OFFICE_BYTES = 20 * 1024 * 1024;
@@ -61,7 +63,7 @@ function createLocalId() {
}
function createUploadId() {
return crypto.randomUUID().replaceAll('-', '');
return uuid().replaceAll('-', '');
}
function extensionOf(file: File) {
@@ -170,11 +172,11 @@ export function createChatDocumentUploads(api: ChatDocumentUploadApi) {
context: ChatDocumentUploadContext,
) {
if (!item.file) return;
item.uploadId ||= createUploadId();
item.status = 'uploading';
item.error = undefined;
const currentLifecycle = lifecycle;
try {
item.uploadId ||= createUploadId();
const response = await api.upload(item.file, context, item.uploadId);
if (response.errorCode !== 0 || !response.data) {
throw new Error(response.message || '文档上传失败');