| 123456789101112131415161718192021222324252627282930313233 |
- import { confirmStore } from "./store";
- const createId = () =>{
- return typeof crypto !== "undefined" && crypto.randomUUID
- ? crypto.randomUUID()
- : `${Date.now()}_${Math.random()}`;
- }
- // let id = createId();
- export function confirmDialog(options: {
- title?: string;
- content?: string | string[];
- noOk?: boolean;
- noCancel?: boolean;
- okBtnTxt?: string;
- cancelBtnTxt?: string;
- }) {
- return new Promise<boolean>((resolve) => {
- const state = confirmStore.getSnapshot();
- confirmStore.setState({
- queue: [
- ...state.queue,
- {
- id: createId(),
- ...options,
- resolve,
- },
- ],
- });
- });
- }
|