fix: allow 500MB async knowledge uploads
This commit is contained in:
@@ -5,6 +5,14 @@ import { resolve } from 'node:path';
|
||||
const read = (path: string) => readFileSync(resolve(process.cwd(), path), 'utf8');
|
||||
|
||||
describe('资料处理媒体重试契约', () => {
|
||||
it('批量队列允许普通文档和图片上传至 500 MiB', () => {
|
||||
const page = read('src/views/knowledge/processing.vue');
|
||||
|
||||
expect(page).toContain('const maxFileSize = 500 * 1024 * 1024');
|
||||
expect(page).toContain('仅支持非空且 500MB 内的 txt/md/pdf/Word/Excel/PPT/图片/视频/ZIP 文件');
|
||||
expect(page).toContain('超过 500MB 的文件');
|
||||
});
|
||||
|
||||
it('把零文本媒体展示为待重试并从原文件重新入队', () => {
|
||||
const api = read('src/api/aihr/processing.ts');
|
||||
const page = read('src/views/knowledge/processing.vue');
|
||||
|
||||
@@ -45,7 +45,9 @@
|
||||
</ul>
|
||||
<el-table v-if="uploadBatch.length" :data="uploadBatch" size="small" max-height="260" class="batch-table">
|
||||
<el-table-column prop="fileName" label="文件名" min-width="220" show-overflow-tooltip />
|
||||
<el-table-column label="目标空间" min-width="180" show-overflow-tooltip><template #default="{ row }">{{ row.spaceCodes?.join('、') || '-' }}</template></el-table-column>
|
||||
<el-table-column label="目标空间" min-width="180" show-overflow-tooltip
|
||||
><template #default="{ row }">{{ row.spaceCodes?.join('、') || '-' }}</template></el-table-column
|
||||
>
|
||||
<el-table-column label="状态" width="96">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="batchItemTagType(row.status)">{{ row.statusLabel }}</el-tag>
|
||||
@@ -151,13 +153,7 @@
|
||||
<el-table-column prop="updatedAt" label="更新时间" width="138" />
|
||||
<el-table-column label="操作" width="86" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="canRetryProcessingTask(row)"
|
||||
link
|
||||
type="danger"
|
||||
:loading="taskRetryingId === row.id"
|
||||
@click="retryTask(row)"
|
||||
>
|
||||
<el-button v-if="canRetryProcessingTask(row)" link type="danger" :loading="taskRetryingId === row.id" @click="retryTask(row)">
|
||||
重试
|
||||
</el-button>
|
||||
<span v-else>-</span>
|
||||
@@ -281,11 +277,7 @@ import { listPersonalPublishRequests, reviewPersonalPublishRequest, type Persona
|
||||
|
||||
const acceptTypes = '.txt,.md,.markdown,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.jpg,.jpeg,.png,.gif,.webp,.bmp,.mp4,.mov,.avi,.mkv,.webm,.m4v,.zip';
|
||||
const supportedPattern = /\.(txt|md|markdown|pdf|doc|docx|xls|xlsx|ppt|pptx|jpg|jpeg|png|gif|webp|bmp|mp4|mov|avi|mkv|webm|m4v|zip)$/i;
|
||||
const videoPattern = /\.(mp4|mov|avi|mkv|webm|m4v)$/i;
|
||||
const archivePattern = /\.zip$/i;
|
||||
const maxFileSize = 100 * 1024 * 1024;
|
||||
const maxVideoSize = 500 * 1024 * 1024;
|
||||
const maxArchiveSize = 500 * 1024 * 1024;
|
||||
const maxFileSize = 500 * 1024 * 1024;
|
||||
const browserBatchWarnCount = 20;
|
||||
const browserBatchWarnSize = 200 * 1024 * 1024;
|
||||
|
||||
@@ -519,18 +511,13 @@ async function uploadFiles(files: File[]) {
|
||||
ElMessage.warning('请先选择至少一个可管理的知识空间');
|
||||
return;
|
||||
}
|
||||
const readyFiles = files.filter(
|
||||
(file) =>
|
||||
supportedPattern.test(file.name) &&
|
||||
file.size > 0 &&
|
||||
file.size <= (videoPattern.test(file.name) ? maxVideoSize : archivePattern.test(file.name) ? maxArchiveSize : maxFileSize)
|
||||
);
|
||||
const readyFiles = files.filter((file) => supportedPattern.test(file.name) && file.size > 0 && file.size <= maxFileSize);
|
||||
if (readyFiles.length === 0) {
|
||||
ElMessage.warning('仅支持非空的 txt/md/pdf/Word/Excel/PPT/图片(100MB内)、视频或 ZIP(500MB内)文件');
|
||||
ElMessage.warning('仅支持非空且 500MB 内的 txt/md/pdf/Word/Excel/PPT/图片/视频/ZIP 文件');
|
||||
return;
|
||||
}
|
||||
if (readyFiles.length < files.length) {
|
||||
ElMessage.warning(`已跳过 ${files.length - readyFiles.length} 个不支持、空文件或超限文件(文档/图片 100MB、视频/ZIP 500MB)`);
|
||||
ElMessage.warning(`已跳过 ${files.length - readyFiles.length} 个不支持、空文件或超过 500MB 的文件`);
|
||||
}
|
||||
|
||||
const totalSize = readyFiles.reduce((sum, file) => sum + file.size, 0);
|
||||
|
||||
Reference in New Issue
Block a user