From 5aa040c94e90b91b785e7be84e72691894dfa2ee Mon Sep 17 00:00:00 2001 From: PingChuan <1259732256@qq.com> Date: Mon, 20 Apr 2026 17:55:49 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E8=87=AA=E5=BB=BA=20RAG=20?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=BA=94=E7=94=A8=EF=BC=8C=E9=99=90=E5=88=B6?= =?UTF-8?q?=E7=9F=A5=E8=AF=86=E5=BA=93=E6=96=87=E6=A1=A3=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E5=8F=AA=E5=85=81=E8=AE=B8=E4=B8=8A=E4=BC=A0=EF=BC=88?= =?UTF-8?q?".pdf",=20".docx",=20".md",=20".txt"=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dify-dataset-manager/document-upload.tsx | 23 ++++++++++++++++--- .../dify-dataset-manager/document-upload.ts | 4 +++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/components/dify-dataset-manager/document-upload.tsx b/app/components/dify-dataset-manager/document-upload.tsx index b7467c3..4b39b8d 100644 --- a/app/components/dify-dataset-manager/document-upload.tsx +++ b/app/components/dify-dataset-manager/document-upload.tsx @@ -22,14 +22,16 @@ import { Spin, Tooltip, Upload, + message, } from 'antd'; import { useEffect, useState } from 'react'; import type { Segment } from '~/api/dify-dataset/type'; import { useDocumentUpload } from '~/hooks/dify-dataset-manager/document-upload'; import type { DocumentUploadProps, UploadedDocument } from '~/types/dify-dataset-manager/document-upload'; -import { SUPPORTED_FORMATS } from '~/types/dify-dataset-manager/document-upload'; +import { SUPPORTED_ACCEPT, SUPPORTED_FILE_EXTENSIONS, SUPPORTED_FORMATS } from '~/types/dify-dataset-manager/document-upload'; const { Dragger } = Upload; +const MAX_FILE_SIZE_MB = 15; /** * 文档上传组件 @@ -121,9 +123,24 @@ export default function DocumentUpload({ false} + beforeUpload={(file) => { + const lowerName = file.name.toLowerCase(); + const isSupported = SUPPORTED_FILE_EXTENSIONS.some((ext) => lowerName.endsWith(ext)); + if (!isSupported) { + message.error(`仅支持上传 ${SUPPORTED_FORMATS} 格式的文件`); + return Upload.LIST_IGNORE; + } + + const isWithinLimit = file.size / 1024 / 1024 <= MAX_FILE_SIZE_MB; + if (!isWithinLimit) { + message.error(`单个文件大小不能超过 ${MAX_FILE_SIZE_MB}MB`); + return Upload.LIST_IGNORE; + } + + return false; + }} multiple={true} - accept=".txt,.md,.mdx,.pdf,.html,.htm,.xlsx,.xls,.docx,.csv,.vtt,.properties" + accept={SUPPORTED_ACCEPT} showUploadList={false} >

diff --git a/app/types/dify-dataset-manager/document-upload.ts b/app/types/dify-dataset-manager/document-upload.ts index aaf8fbb..541e7ce 100644 --- a/app/types/dify-dataset-manager/document-upload.ts +++ b/app/types/dify-dataset-manager/document-upload.ts @@ -65,7 +65,9 @@ export const INDEXING_STATUS_CONFIG: Record