From a8f3061b3c9350e1570979794e5cb521dd60a2da Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 15 Dec 2025 18:02:34 +0800 Subject: [PATCH] fix: all upload files are disabled if upload file feature disabled (#29681) --- web/app/components/base/chat/chat/chat-input-area/index.tsx | 2 +- web/app/components/base/file-uploader/hooks.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/app/components/base/chat/chat/chat-input-area/index.tsx b/web/app/components/base/chat/chat/chat-input-area/index.tsx index 7d08b84b8e..5004bb2a92 100644 --- a/web/app/components/base/chat/chat/chat-input-area/index.tsx +++ b/web/app/components/base/chat/chat/chat-input-area/index.tsx @@ -79,7 +79,7 @@ const ChatInputArea = ({ handleDropFile, handleClipboardPasteFile, isDragActive, - } = useFile(visionConfig!) + } = useFile(visionConfig!, false) const { checkInputsForm } = useCheckInputsForms() const historyRef = useRef(['']) const [currentIndex, setCurrentIndex] = useState(-1) diff --git a/web/app/components/base/file-uploader/hooks.ts b/web/app/components/base/file-uploader/hooks.ts index baef5ff7d8..2e72574cfb 100644 --- a/web/app/components/base/file-uploader/hooks.ts +++ b/web/app/components/base/file-uploader/hooks.ts @@ -47,7 +47,7 @@ export const useFileSizeLimit = (fileUploadConfig?: FileUploadConfigResponse) => } } -export const useFile = (fileConfig: FileUpload) => { +export const useFile = (fileConfig: FileUpload, noNeedToCheckEnable = true) => { const { t } = useTranslation() const { notify } = useToastContext() const fileStore = useFileStore() @@ -247,7 +247,7 @@ export const useFile = (fileConfig: FileUpload) => { const handleLocalFileUpload = useCallback((file: File) => { // Check file upload enabled - if (!fileConfig.enabled) { + if (!noNeedToCheckEnable && !fileConfig.enabled) { notify({ type: 'error', message: t('common.fileUploader.uploadDisabled') }) return } @@ -303,7 +303,7 @@ export const useFile = (fileConfig: FileUpload) => { false, ) reader.readAsDataURL(file) - }, [checkSizeLimit, notify, t, handleAddFile, handleUpdateFile, params.token, fileConfig?.allowed_file_types, fileConfig?.allowed_file_extensions, fileConfig?.enabled]) + }, [noNeedToCheckEnable, checkSizeLimit, notify, t, handleAddFile, handleUpdateFile, params.token, fileConfig?.allowed_file_types, fileConfig?.allowed_file_extensions, fileConfig?.enabled]) const handleClipboardPasteFile = useCallback((e: ClipboardEvent) => { const file = e.clipboardData?.files[0]