import { useEscapeKey } from '@/lib/hooks'; import { useConfirmDialogStore } from '@/stores/confirmDialog'; /** Mounted once at the app root (App.tsx) -- renders whatever `requestConfirm()` (confirmDialog.ts) * most recently asked for. Visual language matches this app's other small action dialogs (e.g. the * forward picker's outlined-gray "取消" + solid colored confirm button, `02-messages.dc.html`'s own * spec for that pairing) rather than inventing a new button treatment just for this. */ export function ConfirmDialogRoot() { const pending = useConfirmDialogStore((s) => s.pending); const respond = useConfirmDialogStore((s) => s.respond); // Always called (hooks can't be conditional) -- a no-op onEscape while nothing is pending is // harmless, matching how every other modal in this app registers unconditionally too. useEscapeKey(() => respond(false)); if (!pending) return null; const { title, message, confirmLabel = '确定', cancelLabel = '取消', danger } = pending; return (
respond(false)}>
e.stopPropagation()}> {title ? {title} : null}

{message}

); }