import { create } from 'zustand' export interface ConfirmOptions { title: string description?: string confirmText?: string cancelText?: string danger?: boolean onConfirm: () => void | Promise } interface ConfirmState { current: ConfirmOptions | null ask: (opts: ConfirmOptions) => void close: () => void } export const useConfirmStore = create()((set) => ({ current: null, ask: (opts) => set({ current: opts }), close: () => set({ current: null }), })) /** 任意位置调用:confirmDialog({ title, danger, onConfirm }) */ export function confirmDialog(opts: ConfirmOptions): void { useConfirmStore.getState().ask(opts) }