Merge branch 'PingChuan' into shiy-login

This commit is contained in:
2026-04-21 15:09:44 +08:00
2 changed files with 23 additions and 4 deletions
@@ -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({
<Dragger
fileList={fileList}
onChange={handleFileChange}
beforeUpload={() => 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}
>
<p className="ant-upload-drag-icon">
@@ -65,7 +65,9 @@ export const INDEXING_STATUS_CONFIG: Record<IndexingStatus, { text: string; perc
/**
* 支持的文件格式
*/
export const SUPPORTED_FORMATS = 'TXT, MARKDOWN, MDX, PDF, HTML, XLSX, XLS, DOCX, CSV, VTT, PROPERTIES, MD, HTM';
export const SUPPORTED_FILE_EXTENSIONS = ['.pdf', '.docx', '.md', '.txt'] as const;
export const SUPPORTED_FORMATS = 'PDF, DOCX, MD, TXT';
export const SUPPORTED_ACCEPT = SUPPORTED_FILE_EXTENSIONS.join(',');
/**
* 文档上传组件 Props