lijianan
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
12 additions and
10 deletions
-
components/_util/ActionButton.tsx
-
components/back-top/index.tsx
-
components/upload/Upload.tsx
-
components/upload/UploadList/ListItem.tsx
|
@ -22,7 +22,7 @@ function isThenable(thing?: PromiseLike<any>): boolean { |
|
|
|
|
|
|
|
|
const ActionButton: React.FC<ActionButtonProps> = props => { |
|
|
const ActionButton: React.FC<ActionButtonProps> = props => { |
|
|
const clickedRef = React.useRef<boolean>(false); |
|
|
const clickedRef = React.useRef<boolean>(false); |
|
|
const ref = React.useRef<any>(); |
|
|
const ref = React.useRef<HTMLInputElement>(null); |
|
|
const [loading, setLoading] = useState<ButtonProps['loading']>(false); |
|
|
const [loading, setLoading] = useState<ButtonProps['loading']>(false); |
|
|
const { close } = props; |
|
|
const { close } = props; |
|
|
const onInternalClose = (...args: any[]) => { |
|
|
const onInternalClose = (...args: any[]) => { |
|
@ -30,10 +30,11 @@ const ActionButton: React.FC<ActionButtonProps> = props => { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
React.useEffect(() => { |
|
|
React.useEffect(() => { |
|
|
let timeoutId: any; |
|
|
let timeoutId: NodeJS.Timer | null = null; |
|
|
if (props.autoFocus) { |
|
|
if (props.autoFocus) { |
|
|
const $this = ref.current as HTMLInputElement; |
|
|
timeoutId = setTimeout(() => { |
|
|
timeoutId = setTimeout(() => $this.focus()); |
|
|
ref.current?.focus(); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
return () => { |
|
|
return () => { |
|
|
if (timeoutId) { |
|
|
if (timeoutId) { |
|
|
|
@ -56,7 +56,7 @@ const BackTop: React.FC<BackTopProps> = props => { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const ref = React.createRef<HTMLDivElement>(); |
|
|
const ref = React.createRef<HTMLDivElement>(); |
|
|
const scrollEvent = React.useRef<any>(); |
|
|
const scrollEvent = React.useRef<ReturnType<typeof addEventListener>>(null); |
|
|
|
|
|
|
|
|
const getDefaultTarget = () => |
|
|
const getDefaultTarget = () => |
|
|
ref.current && ref.current.ownerDocument ? ref.current.ownerDocument : window; |
|
|
ref.current && ref.current.ownerDocument ? ref.current.ownerDocument : window; |
|
|
|
@ -60,7 +60,7 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr |
|
|
|
|
|
|
|
|
const [dragState, setDragState] = React.useState<string>('drop'); |
|
|
const [dragState, setDragState] = React.useState<string>('drop'); |
|
|
|
|
|
|
|
|
const upload = React.useRef<any>(); |
|
|
const upload = React.useRef<RcUpload>(null); |
|
|
|
|
|
|
|
|
warning( |
|
|
warning( |
|
|
'fileList' in props || !('value' in props), |
|
|
'fileList' in props || !('value' in props), |
|
@ -276,7 +276,7 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr |
|
|
item.status = 'removed'; |
|
|
item.status = 'removed'; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
upload.current?.abort(currentFile); |
|
|
upload.current?.abort(currentFile as RcFile); |
|
|
|
|
|
|
|
|
onInternalChange(currentFile, removedFileList); |
|
|
onInternalChange(currentFile, removedFileList); |
|
|
} |
|
|
} |
|
|
|
@ -82,14 +82,15 @@ const ListItem = React.forwardRef( |
|
|
|
|
|
|
|
|
// Delay to show the progress bar
|
|
|
// Delay to show the progress bar
|
|
|
const [showProgress, setShowProgress] = React.useState(false); |
|
|
const [showProgress, setShowProgress] = React.useState(false); |
|
|
const progressRafRef = React.useRef<any>(); |
|
|
const progressRafRef = React.useRef<NodeJS.Timer | null>(null); |
|
|
React.useEffect(() => { |
|
|
React.useEffect(() => { |
|
|
progressRafRef.current = setTimeout(() => { |
|
|
progressRafRef.current = setTimeout(() => { |
|
|
setShowProgress(true); |
|
|
setShowProgress(true); |
|
|
}, 300); |
|
|
}, 300); |
|
|
|
|
|
|
|
|
return () => { |
|
|
return () => { |
|
|
window.clearTimeout(progressRafRef.current); |
|
|
if (progressRafRef.current) { |
|
|
|
|
|
clearTimeout(progressRafRef.current); |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
}, []); |
|
|
}, []); |
|
|
|
|
|
|
|
|