-
-
- 上传文件
-
-
- 输入网址
-
-
+
+ 上传文件
+
+
+ 输入网址
+
@@ -172,49 +174,37 @@
getCheckboxProps: getCheckboxProps
}">
-
-
- {{ text }}
-
-
-
- {{ text?.toUpperCase() }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ {{ text }}
+
+ {{ text?.toUpperCase() }}
+
+
+
+
+
+
+
+ {{ formatRelativeTime(Math.round(text*1000)) }}
+
+
+
+
+ 索引
+
+
- 索引
-
-
- 删除
-
-
-
- {{ formatRelativeTime(Math.round(text*1000)) }}
+ 删除
+
+
{{ text }}
@@ -625,7 +615,7 @@ const openFileDetail = (record) => {
});
} catch (error) {
console.error(error);
- message.error('获取文件详情失败');
+ message.error('获取文件详情失败!!!!');
state.fileDetailLoading = false;
state.lock = false;
state.fileDetailModalVisible = false;
@@ -682,6 +672,25 @@ const getDatabaseInfo = () => {
}
const deleteFile = (fileId) => {
+ state.lock = true
+ console.debug("deleteFile", databaseId.value, fileId)
+ knowledgeBaseApi.deleteFile(databaseId.value, fileId)
+ .then(data => {
+ console.log(data)
+ message.success(data.message || '删除成功')
+ getDatabaseInfo()
+ })
+ .catch(error => {
+ console.error(error)
+ message.error(error.message || '删除失败')
+ })
+ .finally(() => {
+ state.lock = false
+ })
+}
+
+
+const handleDeleteFile = (fileId) => {
console.log(fileId)
//删除提示
Modal.confirm({
@@ -689,28 +698,65 @@ const deleteFile = (fileId) => {
content: '确定要删除该文件吗?',
okText: '确认',
cancelText: '取消',
- onOk: () => {
- state.lock = true
- knowledgeBaseApi.deleteFile(databaseId.value, fileId)
- .then(data => {
- console.log(data)
- message.success(data.message || '删除成功')
- getDatabaseInfo()
- })
- .catch(error => {
- console.error(error)
- message.error(error.message || '删除失败')
- })
- .finally(() => {
- state.lock = false
- })
- },
+ onOk: () => deleteFile(fileId),
onCancel: () => {
console.log('Cancel');
},
});
}
+
+// 批量删除处理函数
+const handleBatchDelete = () => {
+ if (!canBatchDelete.value) {
+ message.info('没有可删除的文件');
+ return;
+ }
+
+ const files = database.value.files || {};
+ const fileCount = selectedRowKeys.value.length;
+
+ Modal.confirm({
+ title: '批量删除文件',
+ content: `确定要删除选中的 ${fileCount} 个文件吗?`,
+ okText: '确认',
+ cancelText: '取消',
+ onOk: async () => {
+ state.batchDeleting = true;
+ try {
+ const promises = selectedRowKeys.value
+ .filter(fileId => {
+ const file = files[fileId];
+ return !(file.status === 'processing' || file.status === 'waiting');
+ })
+ .map(fileId =>
+ deleteFile(fileId)
+ );
+
+ const results = await Promise.allSettled(promises);
+
+ const succeeded = results.filter(r => r.status === 'fulfilled').length;
+ const failed = results.filter(r => r.status === 'rejected').length;
+
+ if (succeeded > 0) {
+ message.success(`成功删除 ${succeeded} 个文件`);
+ }
+ if (failed > 0) {
+ message.error(`${failed} 个文件删除失败`);
+ }
+
+ selectedRowKeys.value = []; // 清空选择
+ getDatabaseInfo(); // 刷新列表状态
+ } catch (error) {
+ console.error('批量删除出错:', error);
+ message.error('批量删除过程中发生错误');
+ } finally {
+ state.batchDeleting = false;
+ }
+ },
+ });
+};
+
const chunkParams = ref({
chunk_size: 1000,
chunk_overlap: 200,
@@ -803,55 +849,6 @@ const chunkUrls = () => {
});
};
-// 添加到数据库 - 此函数逻辑将被新的 "索引" 按钮替代或移除
-const addToDatabase = () => {
- // if (chunkResults.value.length === 0) {
- // message.error('没有可添加的分块')
- // return
- // }
- // state.adding = true
- // state.lock = true
-
- // // 转换为API需要的格式
- // const fileChunks = {};
- // chunkResults.value.forEach(file => {
- // fileChunks[file.file_id] = file;
- // });
-
- // // 调用add-by-chunks接口将分块添加到数据库
- // knowledgeBaseApi.addByChunks({
- // db_id: databaseId.value,
- // file_chunks: fileChunks
- // })
- // .then(data => {
- // console.log(data)
-
- // if (data.status === 'failed') {
- // message.error(data.message)
- // } else {
- // message.success(data.message)
- // fileList.value = []
- // chunkResults.value = []
- // activeFileKeys.value = []
- // getDatabaseInfo() // 刷新列表
- // }
- // })
- // .catch(error => {
- // console.error(error)
- // message.error(error.message)
- // })
- // .finally(() => {
- // state.adding = false
- // state.lock = false
- // })
- message.info("此功能已通过新的索引流程处理。文件分块后将自动出现在列表中,可单独进行索引。");
-}
-
-const addDocumentByFile = () => {
- // 此函数不再需要,由chunkFiles和addToDatabase替代
- console.log('此功能已被拆分为两个步骤')
-}
-
const columns = [
// { title: '文件ID', dataIndex: 'file_id', key: 'file_id' },
{ title: '文件名', dataIndex: 'filename', key: 'filename', ellipsis: true },
@@ -1070,59 +1067,6 @@ const handleBatchIndex = async () => {
}
};
-// 批量删除处理函数
-const handleBatchDelete = () => {
- if (!canBatchDelete.value) {
- message.info('没有可删除的文件');
- return;
- }
-
- const files = database.value.files || {};
- const fileCount = selectedRowKeys.value.length;
-
- Modal.confirm({
- title: '批量删除文件',
- content: `确定要删除选中的 ${fileCount} 个文件吗?`,
- okText: '确认',
- cancelText: '取消',
- onOk: async () => {
- state.batchDeleting = true;
- state.lock = true;
-
- try {
- const promises = selectedRowKeys.value
- .filter(fileId => {
- const file = files[fileId];
- return !(state.lock || file.status === 'processing' || file.status === 'waiting' || state.indexingFile === file.file_id);
- })
- .map(fileId =>
- knowledgeBaseApi.deleteFile(databaseId.value, fileId)
- );
-
- const results = await Promise.allSettled(promises);
-
- const succeeded = results.filter(r => r.status === 'fulfilled').length;
- const failed = results.filter(r => r.status === 'rejected').length;
-
- if (succeeded > 0) {
- message.success(`成功删除 ${succeeded} 个文件`);
- }
- if (failed > 0) {
- message.error(`${failed} 个文件删除失败`);
- }
-
- selectedRowKeys.value = []; // 清空选择
- getDatabaseInfo(); // 刷新列表状态
- } catch (error) {
- console.error('批量删除出错:', error);
- message.error('批量删除过程中发生错误');
- } finally {
- state.batchDeleting = false;
- state.lock = false;
- }
- },
- });
-};
@@ -1467,6 +1411,7 @@ const handleBatchDelete = () => {
background-color: var(--main-light-6);
border-radius: 8px;
border: 1px solid var(--main-light-3);
+ flex: 0 0 280px;
// box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
.chunking-params {
@@ -1538,6 +1483,26 @@ const handleBatchDelete = () => {
.upload-main {
flex: 1;
+
+ .source-selector {
+ display: flex;
+ gap: 10px;
+ margin-bottom: 16px;
+
+ .upload-mode-selector {
+ cursor: pointer;
+ padding: 8px 16px;
+ border-radius: 8px;
+ background-color: var(--main-light-4);
+ border: 1px solid var(--main-light-3);
+ transition: all 0.2s ease;
+ &.active {
+ color: var(--main-color);
+ background-color: var(--main-10);
+ border-color: var(--main-color);
+ }
+ }
+ }
}
}
@@ -1620,6 +1585,12 @@ const handleBatchDelete = () => {
align-items: center;
min-height: 200px;
}
+
+.ant-modal-footer {
+ display: flex;
+ justify-content: flex-end;
+ gap: 10px;
+}