Files
workspace/code/g3soft-libs/docs/examples/modal/confirm.vue
T
2026-10-08 22:38:34 +08:00

35 lines
1.1 KiB
Vue

<script setup lang="ts">
// 命令式确认框:G3Modal.confirm(options) 返回 { destroy }
import { G3Button, G3Message, G3Modal, G3Space } from '@g3soft/ui'
function openConfirm() {
G3Modal.confirm({
title: '确定删除该分支?',
content: '删除后不可恢复,关联的构建记录会一并清理。',
confirmText: '删除',
cancelText: '再想想',
confirmButtonProps: { danger: true },
onConfirm: () => G3Message.success('已删除'),
onCancel: () => G3Message.info('已取消'),
})
}
// destroy:不等退场动画直接卸载(例如路由切换时清理)
let handle: ReturnType<typeof G3Modal.confirm> | null = null
function openAndDestroy() {
handle = G3Modal.confirm({
title: '3 秒后强制销毁',
content: 'destroy() 会立即关闭并卸载容器,不播放退场动画。',
})
setTimeout(() => handle?.destroy(), 3000)
}
</script>
<template>
<G3Space :size="12" wrap>
<G3Button type="danger-outline" @click="openConfirm">删除确认</G3Button>
<G3Button type="outline" @click="openAndDestroy">演示 destroy()</G3Button>
</G3Space>
</template>