组件
This commit is contained in:
@@ -27,14 +27,38 @@ export class MessageExtend {
|
||||
})
|
||||
}
|
||||
|
||||
// 异步提示弹窗
|
||||
static ShowDialogAsyc(title: string, message: string, onConfirm?: () => Promise<boolean>): Promise<boolean> {
|
||||
return new Promise((resolve) => {
|
||||
showConfirmDialog({
|
||||
title,
|
||||
message,
|
||||
beforeClose: async (action) => {
|
||||
if (action === 'confirm' && onConfirm) {
|
||||
const result = await onConfirm()
|
||||
if (result) {
|
||||
resolve(true)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
resolve(action === 'confirm')
|
||||
return true
|
||||
},
|
||||
}).catch(() => {
|
||||
resolve(false) // 捕获取消操作,返回 false
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 成功失败默认提示
|
||||
static ShowToast(text: any, type?: 'success' | 'fail' | 'default') {
|
||||
if (type == 'success') {
|
||||
showSuccessToast(text)
|
||||
} else if (type == 'fail') {
|
||||
showFailToast(text)
|
||||
} else {
|
||||
console.log(text);
|
||||
} else {
|
||||
console.log(text)
|
||||
showToast(text)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user