fix: all upload files are disabled if upload file feature disabled (#29681)

This commit is contained in:
Joel
2025-12-15 18:02:34 +08:00
committed by GitHub
parent bd7b1fc6fb
commit a8f3061b3c
2 changed files with 4 additions and 4 deletions

View File

@@ -79,7 +79,7 @@ const ChatInputArea = ({
handleDropFile, handleDropFile,
handleClipboardPasteFile, handleClipboardPasteFile,
isDragActive, isDragActive,
} = useFile(visionConfig!) } = useFile(visionConfig!, false)
const { checkInputsForm } = useCheckInputsForms() const { checkInputsForm } = useCheckInputsForms()
const historyRef = useRef(['']) const historyRef = useRef([''])
const [currentIndex, setCurrentIndex] = useState(-1) const [currentIndex, setCurrentIndex] = useState(-1)

View File

@@ -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 { t } = useTranslation()
const { notify } = useToastContext() const { notify } = useToastContext()
const fileStore = useFileStore() const fileStore = useFileStore()
@@ -247,7 +247,7 @@ export const useFile = (fileConfig: FileUpload) => {
const handleLocalFileUpload = useCallback((file: File) => { const handleLocalFileUpload = useCallback((file: File) => {
// Check file upload enabled // Check file upload enabled
if (!fileConfig.enabled) { if (!noNeedToCheckEnable && !fileConfig.enabled) {
notify({ type: 'error', message: t('common.fileUploader.uploadDisabled') }) notify({ type: 'error', message: t('common.fileUploader.uploadDisabled') })
return return
} }
@@ -303,7 +303,7 @@ export const useFile = (fileConfig: FileUpload) => {
false, false,
) )
reader.readAsDataURL(file) 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<HTMLTextAreaElement>) => { const handleClipboardPasteFile = useCallback((e: ClipboardEvent<HTMLTextAreaElement>) => {
const file = e.clipboardData?.files[0] const file = e.clipboardData?.files[0]