iter(g112): 消息提示支持撤销类操作

This commit is contained in:
HIsheR
2026-10-26 14:05:38 +08:00
parent bf1bd2241b
commit 5372fdd1f3
8 changed files with 68 additions and 5 deletions
+4 -1
View File
@@ -29,8 +29,11 @@ export function showToast(props: ToastProps): HTMLElement {
let startedAt = 0; // 本段计时起点,用于折算剩余
const item = h(
'div',
{ class: `ua-toast ua-toast-${props.variant ?? 'info'}${props.closable ? ' is-closable' : ''}`, role: 'status', id: `ua-toast-${++seq}` },
{ class: `ua-toast ua-toast-${props.variant ?? 'info'}${props.closable ? ' is-closable' : ''}${props.actionLabel ? ' is-action' : ''}`, role: 'status', id: `ua-toast-${++seq}` },
h('span', { class: 'ua-toast-msg' }, props.message),
props.actionLabel
? h('button', { type: 'button', class: 'ua-toast-action', onClick: () => { dismiss(item); props.onAction?.(); } }, props.actionLabel) // 操作按钮(如撤销):点完立即收起再回调
: null,
props.closable ? h('button', { type: 'button', class: 'ua-toast-close', 'aria-label': '关闭提示', onClick: () => dismiss(item) }, '×') : null,
);
const stack = ensureHost();