From 8d61dcc8ab3869c3f9d671936cf3903a02307223 Mon Sep 17 00:00:00 2001 From: yihong Date: Fri, 7 Mar 2025 11:24:23 +0800 Subject: [PATCH] Fix: can not upload file close #5730 (#5742) ### What problem does this PR solve? _Briefly describe what this PR aims to solve. Include background context that will help reviewers understand the purpose of the PR._ close #5730 ### Type of change - [ ] Bug Fix (non-breaking change which fixes an issue) - [ ] New Feature (non-breaking change which adds functionality) - [ ] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe): Signed-off-by: yihong0618 --- web/src/components/file-upload-modal/index.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/web/src/components/file-upload-modal/index.tsx b/web/src/components/file-upload-modal/index.tsx index 6074fc0a2..7577dcea2 100644 --- a/web/src/components/file-upload-modal/index.tsx +++ b/web/src/components/file-upload-modal/index.tsx @@ -41,6 +41,7 @@ const FileUpload = ({ }, beforeUpload: (file: UploadFile) => { setFileList((pre) => { + console.log(file); return [...pre, file]; }); @@ -68,11 +69,12 @@ const FileUpload = ({ ); }; -interface IFileUploadModalProps extends IModalProps { +interface IFileUploadModalProps extends Omit, 'onOk'> { uploadFileList: UploadFile[]; setUploadFileList: Dispatch>; uploadProgress: number; setUploadProgress: Dispatch>; + onOk?: (fileList: UploadFile[]) => Promise | boolean | void; } const FileUploadModal = ({ @@ -80,19 +82,21 @@ const FileUploadModal = ({ hideModal, loading, onOk: onFileUploadOk, - uploadFileList: fileList, - setUploadFileList: setFileList, uploadProgress, setUploadProgress, }: IFileUploadModalProps) => { const { t } = useTranslate('fileManager'); const [value, setValue] = useState('local'); const [parseOnCreation, setParseOnCreation] = useState(false); + const [fileList, setFileList] = useState([]); const clearFileList = () => { setFileList([]); - setUploadProgress(0); + if (typeof setUploadProgress === 'function') { + setUploadProgress(0); + } }; + console.log(fileList); const onOk = async () => { if (uploadProgress === 100) { @@ -100,7 +104,7 @@ const FileUploadModal = ({ return; } - const ret = await onFileUploadOk?.(parseOnCreation); + const ret = await onFileUploadOk?.(fileList); return ret; };