|
|
@@ -18,7 +18,13 @@
|
|
|
<div class="kd-modal__bar">
|
|
|
<span class="kd-modal__hint">文档按上传者隔离:这里只显示我上传的文件;方案绑定知识库后,对话会检索库内全部文档。</span>
|
|
|
<span class="kd-modal__sp"></span>
|
|
|
- <a-upload :show-upload-list="false" :before-upload="onPickFile" :accept="acceptStr" :disabled="uploading">
|
|
|
+ <a-upload
|
|
|
+ multiple
|
|
|
+ :show-upload-list="false"
|
|
|
+ :before-upload="onPickFile"
|
|
|
+ :accept="acceptStr"
|
|
|
+ :disabled="uploading"
|
|
|
+ >
|
|
|
<a-button type="primary" :loading="uploading">
|
|
|
<template #icon><Icon icon="mdi:upload-outline" :size="14" /></template>
|
|
|
上传文档
|
|
|
@@ -101,7 +107,7 @@
|
|
|
* - 下载:fetch 带 x-token 拿 blob 触发保存(直链不带登录态),后端记下载审计;
|
|
|
* - 重试:仅 FAILED 出现(提取失败/嵌入服务临时不可用),重新走 PENDING → 索引。
|
|
|
*/
|
|
|
- import { onBeforeUnmount, ref, watch } from 'vue';
|
|
|
+ import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
|
|
import { Button, Modal, Table, Tag, Tooltip, Upload } from 'ant-design-vue';
|
|
|
import { BasicModal } from '@/core/components/Modal';
|
|
|
import Icon from '@/core/components/Icon/src/Icon.vue';
|
|
|
@@ -129,7 +135,10 @@
|
|
|
|
|
|
const docs = ref<KnowledgeDoc[]>([]);
|
|
|
const loading = ref(false);
|
|
|
- const uploading = ref(false);
|
|
|
+ const uploadingCount = ref(0);
|
|
|
+ const uploading = computed(() => uploadingCount.value > 0);
|
|
|
+ /** 多选文件串行上传:避免并发 upload + load 互相覆盖列表 */
|
|
|
+ let uploadQueue: Promise<void> = Promise.resolve();
|
|
|
let pollTimer: ReturnType<typeof setTimeout> | null = null;
|
|
|
|
|
|
// 选择器与数据上传页共用全局格式清单(core/constants/fileFormats.ts);
|
|
|
@@ -196,21 +205,23 @@
|
|
|
|
|
|
/** antd before-upload 返回 false 阻止自动上传,这里手动接管 */
|
|
|
function onPickFile(file: File) {
|
|
|
- void doUpload(file);
|
|
|
+ uploadingCount.value += 1;
|
|
|
+ uploadQueue = uploadQueue
|
|
|
+ .then(() => doUpload(file))
|
|
|
+ .finally(() => {
|
|
|
+ uploadingCount.value = Math.max(0, uploadingCount.value - 1);
|
|
|
+ });
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
async function doUpload(file: File) {
|
|
|
if (!props.kb) return;
|
|
|
- uploading.value = true;
|
|
|
try {
|
|
|
await knowledgeApi.uploadDoc(props.kb.id, file);
|
|
|
- showMessage('已上传,正在解析并向量化', 'success');
|
|
|
+ showMessage(`「${file.name}」已上传,正在解析并向量化`, 'success');
|
|
|
await load();
|
|
|
} catch (e: any) {
|
|
|
- showMessage(e?.message || '上传失败', 'error');
|
|
|
- } finally {
|
|
|
- uploading.value = false;
|
|
|
+ showMessage(e?.message || `「${file.name}」上传失败`, 'error');
|
|
|
}
|
|
|
}
|
|
|
|