mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-15 21:35:55 +08:00
### What problem does this PR solve? Fix: Fixed the issue that files cannot be uploaded on the file management page. #5730 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
da3f279495
commit
3c79990934
@ -28,7 +28,7 @@ const FileUpload = ({
|
|||||||
directory: boolean;
|
directory: boolean;
|
||||||
fileList: UploadFile[];
|
fileList: UploadFile[];
|
||||||
setFileList: Dispatch<SetStateAction<UploadFile[]>>;
|
setFileList: Dispatch<SetStateAction<UploadFile[]>>;
|
||||||
uploadProgress: number;
|
uploadProgress?: number;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslate('fileManager');
|
const { t } = useTranslate('fileManager');
|
||||||
const props: UploadProps = {
|
const props: UploadProps = {
|
||||||
@ -41,7 +41,6 @@ const FileUpload = ({
|
|||||||
},
|
},
|
||||||
beforeUpload: (file: UploadFile) => {
|
beforeUpload: (file: UploadFile) => {
|
||||||
setFileList((pre) => {
|
setFileList((pre) => {
|
||||||
console.log(file);
|
|
||||||
return [...pre, file];
|
return [...pre, file];
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -69,12 +68,11 @@ const FileUpload = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
interface IFileUploadModalProps extends Omit<IModalProps<boolean>, 'onOk'> {
|
interface IFileUploadModalProps extends IModalProps<boolean | UploadFile[]> {
|
||||||
uploadFileList: UploadFile[];
|
uploadFileList?: UploadFile[];
|
||||||
setUploadFileList: Dispatch<SetStateAction<UploadFile[]>>;
|
setUploadFileList?: Dispatch<SetStateAction<UploadFile[]>>;
|
||||||
uploadProgress: number;
|
uploadProgress?: number;
|
||||||
setUploadProgress: Dispatch<SetStateAction<number>>;
|
setUploadProgress?: Dispatch<SetStateAction<number>>;
|
||||||
onOk?: (fileList: UploadFile[]) => Promise<boolean | void> | boolean | void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const FileUploadModal = ({
|
const FileUploadModal = ({
|
||||||
@ -82,21 +80,26 @@ const FileUploadModal = ({
|
|||||||
hideModal,
|
hideModal,
|
||||||
loading,
|
loading,
|
||||||
onOk: onFileUploadOk,
|
onOk: onFileUploadOk,
|
||||||
|
uploadFileList: fileList,
|
||||||
|
setUploadFileList: setFileList,
|
||||||
uploadProgress,
|
uploadProgress,
|
||||||
setUploadProgress,
|
setUploadProgress,
|
||||||
}: IFileUploadModalProps) => {
|
}: IFileUploadModalProps) => {
|
||||||
const { t } = useTranslate('fileManager');
|
const { t } = useTranslate('fileManager');
|
||||||
const [value, setValue] = useState<string | number>('local');
|
const [value, setValue] = useState<string | number>('local');
|
||||||
const [parseOnCreation, setParseOnCreation] = useState(false);
|
const [parseOnCreation, setParseOnCreation] = useState(false);
|
||||||
const [fileList, setFileList] = useState<UploadFile[]>([]);
|
const [currentFileList, setCurrentFileList] = useState<UploadFile[]>([]);
|
||||||
|
const [directoryFileList, setDirectoryFileList] = useState<UploadFile[]>([]);
|
||||||
|
|
||||||
const clearFileList = () => {
|
const clearFileList = () => {
|
||||||
setFileList([]);
|
if (setFileList) {
|
||||||
if (typeof setUploadProgress === 'function') {
|
setFileList([]);
|
||||||
setUploadProgress(0);
|
setUploadProgress?.(0);
|
||||||
|
} else {
|
||||||
|
setCurrentFileList([]);
|
||||||
}
|
}
|
||||||
|
setDirectoryFileList([]);
|
||||||
};
|
};
|
||||||
console.log(fileList);
|
|
||||||
|
|
||||||
const onOk = async () => {
|
const onOk = async () => {
|
||||||
if (uploadProgress === 100) {
|
if (uploadProgress === 100) {
|
||||||
@ -104,7 +107,9 @@ const FileUploadModal = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ret = await onFileUploadOk?.(fileList);
|
const ret = await onFileUploadOk?.(
|
||||||
|
fileList ? parseOnCreation : [...currentFileList, ...directoryFileList],
|
||||||
|
);
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -119,8 +124,8 @@ const FileUploadModal = ({
|
|||||||
children: (
|
children: (
|
||||||
<FileUpload
|
<FileUpload
|
||||||
directory={false}
|
directory={false}
|
||||||
fileList={fileList}
|
fileList={fileList ? fileList : currentFileList}
|
||||||
setFileList={setFileList}
|
setFileList={setFileList ? setFileList : setCurrentFileList}
|
||||||
uploadProgress={uploadProgress}
|
uploadProgress={uploadProgress}
|
||||||
></FileUpload>
|
></FileUpload>
|
||||||
),
|
),
|
||||||
@ -131,8 +136,8 @@ const FileUploadModal = ({
|
|||||||
children: (
|
children: (
|
||||||
<FileUpload
|
<FileUpload
|
||||||
directory
|
directory
|
||||||
fileList={fileList}
|
fileList={directoryFileList}
|
||||||
setFileList={setFileList}
|
setFileList={setDirectoryFileList}
|
||||||
uploadProgress={uploadProgress}
|
uploadProgress={uploadProgress}
|
||||||
></FileUpload>
|
></FileUpload>
|
||||||
),
|
),
|
||||||
|
@ -238,7 +238,7 @@ export const useHandleUploadDocument = () => {
|
|||||||
|
|
||||||
return code;
|
return code;
|
||||||
},
|
},
|
||||||
[uploadDocument, hideDocumentUploadModal, fileList],
|
[fileList, uploadDocument, hideDocumentUploadModal, runDocumentByIds],
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user