From ff886b14e8656cf1aaec92578c7939cd8647bd8f Mon Sep 17 00:00:00 2001 From: dolphin Date: Wed, 17 Sep 2025 17:50:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=A1=E8=AE=A1=E6=BA=AF=E6=BA=90?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/bs-icons/file/index.tsx | 5 +++-- .../platform/src/controllers/API/index.ts | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/frontend/platform/src/components/bs-icons/file/index.tsx b/src/frontend/platform/src/components/bs-icons/file/index.tsx index 6fd8dc2ea..b173b37ba 100644 --- a/src/frontend/platform/src/components/bs-icons/file/index.tsx +++ b/src/frontend/platform/src/components/bs-icons/file/index.tsx @@ -16,7 +16,7 @@ export type FileType = | 'docx' | 'ppt' | 'pptx' - | 'md' | 'html' | 'txt' + | 'md' | 'html' | 'txt' | 'json' | 'jpg' | 'jpeg' | 'png' @@ -29,6 +29,7 @@ export type FileType = const iconComponents: Record> = { pdf: PdfIcon, txt: TxtIcon, + json: TxtIcon, doc: DocIcon, docx: DocxIcon, ppt: PptIcon, @@ -58,7 +59,7 @@ export const FileIcon = forwardRef< if (!IconComponent) { console.warn(`No icon found for type: ${props.type}`); - return null; + return ; } return ; diff --git a/src/frontend/platform/src/controllers/API/index.ts b/src/frontend/platform/src/controllers/API/index.ts index ad0e0e440..4a1b86a6f 100644 --- a/src/frontend/platform/src/controllers/API/index.ts +++ b/src/frontend/platform/src/controllers/API/index.ts @@ -790,7 +790,7 @@ export async function getSourceChunksApi(chatId: string, messageId: number, keys }); return Object.keys(fileMap).map(fileId => { - const { file_id: id, source: fileName, source_url: fileUrl, original_url: originUrl, ...other } = fileMap[fileId][0] + const { file_id: id, source: fileName, source_url, original_url: originUrl, ...other } = fileMap[fileId][0] const chunks = fileMap[fileId].sort((a, b) => b.score - a.score) .map(chunk => ({ @@ -799,7 +799,20 @@ export async function getSourceChunksApi(chatId: string, messageId: number, keys })) const score = chunks[0].score - return { id, fileName, fileUrl, originUrl, chunks, ...other, score } + // 兼容后端历史逻辑 + let fileUrl = '' + let suffix = fileName.split('.').pop().toLowerCase() + let isNew = false + if (['uns', 'local'].includes(other.parse_type)) { + fileUrl = other.chunk_bboxes ? source_url : originUrl; + if (other.chunk_bboxes) { + suffix = 'pdf' + } + } else if (['etl4lm', 'un_etl4lm'].includes(other.parse_type)) { + fileUrl = source_url || originUrl + isNew = true + } + return { id, fileName, suffix, isNew, fileUrl, originUrl, chunks, ...other, score } }).sort((a, b) => b.score - a.score) } catch (error) { console.error(error);