iter(g167): 弹窗支持内置页脚与异步确认

This commit is contained in:
HIsheR
2026-10-26 16:14:19 +08:00
parent b6a6827f9b
commit ff9442904b
7 changed files with 78 additions and 17 deletions
+6 -9
View File
@@ -576,19 +576,16 @@ const content = h(
),
modal(
{
title: '确认操作',
title: '确认操作(内置页脚 · 异步确认)',
open: modalOpen,
size: 'lg',
confirmText: '确认提交',
cancelText: '再想想',
onClose: () => modalOpen(false),
footer: h(
'div',
{ class: 'row' },
button({ label: '取消', variant: 'ghost', onClick: () => modalOpen(false) }),
button({ label: '确定', onClick: () => { modalOpen(false); toast.success('已确认'); } }),
),
onConfirm: async () => { await new Promise((r) => setTimeout(r, 900)); toast.success('已确认,窗口自动关闭'); }, // 成功后组件自己收窗
},
h('p', null, '这是一个由信号驱动的弹窗组件(size: lg + footer 操作区)。'),
h('div', { class: 'row' }, badge({ label: 'modal', variant: 'success' }), badge({ label: 'footer', variant: 'default' })),
h('p', null, '不传 footer 时走内置按钮组:onConfirm 返回 Promise 期间按钮变「处理中…」并禁用,成功才收窗,失败留在窗口重试(提示交给调用方的 toast)。'),
h('div', { class: 'row' }, badge({ label: 'modal', variant: 'success' }), badge({ label: 'onConfirm', variant: 'default' })),
select({ options: [{ value: 'a', label: '优先处理' }, { value: 'b', label: '排队等待' }, { value: 'c', label: '转交他人' }], value: modalPick }),
),
),