fix: 🐛 修复 Upload 组件自定义上传方法不支持asyncfunction的问题 (#890)

 Closes: #859
This commit is contained in:
不如摸鱼去 2025-02-12 14:04:59 +08:00 committed by GitHub
parent ebbe7e4079
commit 25649dbca5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 8 deletions

View File

@ -315,7 +315,7 @@ export function isArray(value: any): value is Array<any> {
*/
// eslint-disable-next-line @typescript-eslint/ban-types
export function isFunction<T extends Function>(value: any): value is T {
return getType(value) === 'function'
return getType(value) === 'function' || getType(value) === 'asyncfunction'
}
/**

View File

@ -124,7 +124,7 @@ export type UploadMethod = (
onError: (res: UniApp.GeneralCallbackResult, file: UploadFileItem, formData: UploadFormData) => void
onProgress: (res: UniApp.OnProgressUpdateResult, file: UploadFileItem) => void
}
) => void
) => void | Promise<void>
export const uploadProps = {
...baseProps,

View File

@ -178,7 +178,7 @@ watch(
watch(
() => props.beforePreview,
(fn) => {
if (fn && !isFunction(fn) && getType(fn) !== 'asyncfunction') {
if (fn && !isFunction(fn)) {
console.error('The type of beforePreview must be Function')
}
},
@ -191,7 +191,7 @@ watch(
watch(
() => props.onPreviewFail,
(fn) => {
if (fn && !isFunction(fn) && getType(fn) !== 'asyncfunction') {
if (fn && !isFunction(fn)) {
console.error('The type of onPreviewFail must be Function')
}
},
@ -204,7 +204,7 @@ watch(
watch(
() => props.beforeRemove,
(fn) => {
if (fn && !isFunction(fn) && getType(fn) !== 'asyncfunction') {
if (fn && !isFunction(fn)) {
console.error('The type of beforeRemove must be Function')
}
},
@ -217,7 +217,7 @@ watch(
watch(
() => props.beforeUpload,
(fn) => {
if (fn && !isFunction(fn) && getType(fn) !== 'asyncfunction') {
if (fn && !isFunction(fn)) {
console.error('The type of beforeUpload must be Function')
}
},
@ -230,7 +230,7 @@ watch(
watch(
() => props.beforeChoose,
(fn) => {
if (fn && !isFunction(fn) && getType(fn) !== 'asyncfunction') {
if (fn && !isFunction(fn)) {
console.error('The type of beforeChoose must be Function')
}
},
@ -243,7 +243,7 @@ watch(
watch(
() => props.buildFormData,
(fn) => {
if (fn && !isFunction(fn) && getType(fn) !== 'asyncfunction') {
if (fn && !isFunction(fn)) {
console.error('The type of buildFormData must be Function')
}
},