From 8d8b062e6bcba40713a4965b050ca7ec38fe7936 Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Thu, 3 Jul 2025 16:48:58 +0800 Subject: [PATCH] add max count to image import (#5144) --- .../dataset/detail/components/FileSelector.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/projects/app/src/pageComponents/dataset/detail/components/FileSelector.tsx b/projects/app/src/pageComponents/dataset/detail/components/FileSelector.tsx index 50fdf3888..c5db5c1dc 100644 --- a/projects/app/src/pageComponents/dataset/detail/components/FileSelector.tsx +++ b/projects/app/src/pageComponents/dataset/detail/components/FileSelector.tsx @@ -39,16 +39,19 @@ const FileSelector = ({ const systemMaxSize = (feConfigs?.uploadFileMaxSize || 1024) * 1024 * 1024; const displayMaxSize = maxSize || formatFileSize(systemMaxSize); + const formatMaxCount = feConfigs.uploadFileMaxAmount + ? Math.min(maxCount, feConfigs.uploadFileMaxAmount) + : maxCount; const { File, onOpen } = useSelectFile({ fileType, - multiple: maxCount > 1, - maxCount + multiple: formatMaxCount > 1, + maxCount: formatMaxCount }); const [isDragging, setIsDragging] = useState(false); const isMaxSelected = useMemo( - () => selectFiles.length >= maxCount, - [maxCount, selectFiles.length] + () => selectFiles.length >= formatMaxCount, + [formatMaxCount, selectFiles.length] ); const filterTypeReg = new RegExp( @@ -68,10 +71,10 @@ const FileSelector = ({ size: formatFileSize(file.size) })); - const newFiles = [...fileList, ...selectFiles].slice(0, maxCount); + const newFiles = [...fileList, ...selectFiles].slice(0, formatMaxCount); setSelectFiles(newFiles); }, - [maxCount, selectFiles, setSelectFiles] + [formatMaxCount, selectFiles, setSelectFiles] ); const handleDragEnter = (e: DragEvent) => { @@ -206,7 +209,7 @@ const FileSelector = ({ )} {/* max count */} - {maxCount && <>{t('file:support_max_count', { maxCount })}, } + {formatMaxCount && <>{t('file:support_max_count', { maxCount: formatMaxCount })}, } {/* max size */} {t('file:support_max_size', { maxSize: displayMaxSize })}