v4.6.4-Outlink (#589)

This commit is contained in:
Archer
2023-12-12 14:42:20 +08:00
committed by GitHub
parent d2d7eac9e0
commit e18c79ca71
79 changed files with 1094 additions and 762 deletions

View File

@@ -12,9 +12,10 @@ export const useSelectFile = (props?: {
const { fileType = '*', multiple = false, maxCount = 10 } = props || {};
const { toast } = useToast();
const SelectFileDom = useRef<HTMLInputElement>(null);
const openSign = useRef<any>();
const File = useCallback(
({ onSelect }: { onSelect: (e: File[]) => void }) => (
({ onSelect }: { onSelect: (e: File[], sign?: any) => void }) => (
<Box position={'absolute'} w={0} h={0} overflow={'hidden'}>
<input
ref={SelectFileDom}
@@ -29,7 +30,7 @@ export const useSelectFile = (props?: {
title: t('file.Select a maximum of 10 files')
});
}
onSelect(Array.from(e.target.files));
onSelect(Array.from(e.target.files), openSign.current);
}}
/>
</Box>
@@ -37,7 +38,8 @@ export const useSelectFile = (props?: {
[fileType, maxCount, multiple]
);
const onOpen = useCallback(() => {
const onOpen = useCallback((sign?: any) => {
openSign.current = sign;
SelectFileDom.current && SelectFileDom.current.click();
}, []);

View File

@@ -233,10 +233,10 @@ export const fileDownload = ({
};
export const fileToBase64 = (file: File) => {
return new Promise((resolve, reject) => {
return new Promise<string>((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onload = () => resolve(reader.result as string);
reader.onerror = (error) => reject(error);
});
};