Skip to content

Commit

Permalink
fix: 🐛 修复 Upload 组件自定义上传方法不支持asyncfunction的问题 (#890)
Browse files Browse the repository at this point in the history
Closes: #859
  • Loading branch information
Moonofweisheng authored Feb 12, 2025
1 parent ebbe7e4 commit 25649db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/uni_modules/wot-design-uni/components/common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
},
Expand All @@ -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')
}
},
Expand All @@ -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')
}
},
Expand All @@ -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')
}
},
Expand All @@ -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')
}
},
Expand All @@ -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')
}
},
Expand Down

0 comments on commit 25649db

Please sign in to comment.