fix: cannot save the system model setting #468 (#508)

### What problem does this PR solve?

fix: cannot save the system model setting #468
feat: rename file in FileManager
feat: add FileManager
feat: override useSelector type

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2024-04-23 17:46:56 +08:00
committed by GitHub
parent aa71462a9f
commit 6405041b4d
22 changed files with 990 additions and 70 deletions

View File

@@ -0,0 +1,80 @@
import { IFileListRequestBody } from '@/interfaces/request/file-manager';
import { useCallback } from 'react';
import { useDispatch, useSelector } from 'umi';
export const useFetchFileList = () => {
const dispatch = useDispatch();
const fetchFileList = useCallback(
(payload: IFileListRequestBody) => {
return dispatch<any>({
type: 'fileManager/listFile',
payload,
});
},
[dispatch],
);
return fetchFileList;
};
export const useRemoveFile = () => {
const dispatch = useDispatch();
const removeFile = useCallback(
(fileIds: string[]) => {
return dispatch<any>({
type: 'fileManager/removeFile',
payload: { fileIds },
});
},
[dispatch],
);
return removeFile;
};
export const useRenameFile = () => {
const dispatch = useDispatch();
const renameFile = useCallback(
(fileId: string, name: string) => {
return dispatch<any>({
type: 'fileManager/renameFile',
payload: { fileId, name },
});
},
[dispatch],
);
return renameFile;
};
export const useFetchParentFolderList = () => {
const dispatch = useDispatch();
const fetchParentFolderList = useCallback(
(fileId: string) => {
return dispatch<any>({
type: 'fileManager/getAllParentFolder',
payload: { fileId },
});
},
[dispatch],
);
return fetchParentFolderList;
};
export const useSelectFileList = () => {
const fileList = useSelector((state) => state.fileManager.fileList);
return fileList;
};
export const useSelectParentFolderList = () => {
const parentFolderList = useSelector(
(state) => state.fileManager.parentFolderList,
);
return parentFolderList.toReversed();
};