u
This commit is contained in:
1 parent
f572dce2f6
commit
e99a9fb274
356 files changed
+28877
-1055
No files matched your search
@@ -0,0 +1,35 @@
|
||||
<script setup lang="ts">
|
||||
// 异步确认:onConfirm 返回 Promise 时按钮进入 loading
|
||||
// resolve → 关闭;reject → 保持打开,让用户重试或取消
|
||||
import { G3Button, G3Message, G3Modal, G3Space } from '@g3soft/ui'
|
||||
|
||||
function openSuccess() {
|
||||
G3Modal.confirm({
|
||||
title: '提交审批',
|
||||
content: 'onConfirm 返回 Promise,等待期间按钮显示 loading。',
|
||||
onConfirm: async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 1200))
|
||||
G3Message.success('审批已提交')
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function openFailure() {
|
||||
G3Modal.confirm({
|
||||
title: '可能失败的提交',
|
||||
content: '这次会 reject:弹窗保持打开,按钮恢复可点。',
|
||||
onConfirm: async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000))
|
||||
G3Message.error('服务不可用,请重试')
|
||||
throw new Error('failed')
|
||||
},
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<G3Space :size="12" wrap>
|
||||
<G3Button @click="openSuccess">异步成功</G3Button>
|
||||
<G3Button type="outline" @click="openFailure">异步失败</G3Button>
|
||||
</G3Space>
|
||||
</template>
|
||||
Reference in new issue
Block a user