This commit is contained in:
oneao committed 2025-09-17 17:31:00 +08:00
1 parent 4d0d2f875e
commit 27263365ad
13 files changed
+265 -21

No files matched your search

@@ -20,9 +20,8 @@ export default defineComponent({
type: [String, Object, Function] as unknown as () => string | VNode | (() => VNode),
required: false,
},
asyncConfirm: {
type: Boolean,
default: false, // 默认同步关闭,不显示 loading
beforeConfirm: {
type: Function as PropType<() => boolean | Promise<boolean>>,
},
confirmBtn: {
type: null,
@@ -68,21 +67,20 @@ export default defineComponent({
return val
}
const handleConfirm = () => {
if (props.asyncConfirm) {
confirmLoading.value = true
const handleConfirm = async () => {
confirmLoading.value = true
let allow = true
emit('confirm', () => { // resolve
popVisible.value = false
confirmLoading.value = false
}, () => { // reject
confirmLoading.value = false
})
if (props.beforeConfirm) {
allow = await Promise.resolve(props.beforeConfirm())
}
else {
if (allow) {
popVisible.value = false
emit('confirm')
}
confirmLoading.value = false
}
const handleCancel = () => {