From cc06d07016ba21f8a319367a66d6a16c2fba49de Mon Sep 17 00:00:00 2001 From: CaptainB Date: Tue, 1 Jul 2025 15:58:28 +0800 Subject: [PATCH] refactor: enhance document download function with additional parameter and add new MIME types --- apps/oss/serializers/file.py | 1 + ui/src/api/knowledge/document.ts | 5 +++-- ui/src/views/document/index.vue | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/oss/serializers/file.py b/apps/oss/serializers/file.py index b9cbe218..63406a02 100644 --- a/apps/oss/serializers/file.py +++ b/apps/oss/serializers/file.py @@ -50,6 +50,7 @@ mime_types = { "webm": "video/webm", "flv": "video/x-flv", "m4v": "video/x-m4v", "mng": "video/x-mng", "asx": "video/x-ms-asf", "asf": "video/x-ms-asf", "wmv": "video/x-ms-wmv", "avi": "video/x-msvideo", "wav": "audio/wav", "flac": "audio/flac", "aac": "audio/aac", "opus": "audio/opus", + "csv": "text/csv", "tsv": "text/tab-separated-values", "ics": "text/calendar", } diff --git a/ui/src/api/knowledge/document.ts b/ui/src/api/knowledge/document.ts index 129b33a3..806ffa0f 100644 --- a/ui/src/api/knowledge/document.ts +++ b/ui/src/api/knowledge/document.ts @@ -136,11 +136,12 @@ const putCancelTask: ( * 下载原文档 * @param 参数 knowledge_id */ -const getDownloadSourceFile: (knowledge_id: string, document_id: string) => Promise> = ( +const getDownloadSourceFile: (knowledge_id: string, document_id: string, document_name: string) => Promise> = ( knowledge_id, document_id, + document_name, ) => { - return get(`${prefix.value}/${knowledge_id}/document/${document_id}/download_source_file`) + return exportFile(document_name, `${prefix.value}/${knowledge_id}/document/${document_id}/download_source_file`, {}, undefined) } /** diff --git a/ui/src/views/document/index.vue b/ui/src/views/document/index.vue index d70d717d..c080fce5 100644 --- a/ui/src/views/document/index.vue +++ b/ui/src/views/document/index.vue @@ -944,7 +944,7 @@ function batchRefresh() { function downloadDocument(row: any) { loadSharedApi({ type: 'document', systemType: apiType.value }) - .getDownloadSourceFile(id, row.id) + .getDownloadSourceFile(id, row.id, row.name) .then(() => { getList() })