This commit is contained in:
Ls
2026-04-28 17:59:39 +08:00
parent 2996fa712c
commit ea1cfc4a37
4 changed files with 194 additions and 5 deletions

View File

@@ -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)
}
}