import { Modal } from "ant-design-vue";
import { InfoCircleFilled } from "@ant-design/icons-vue";
import { createVNode } from "vue";

interface ConfirmOption {
  title?: string;
  content: string;
}

export async function showConfirm(option: ConfirmOption): Promise<"confirm"> {
  return new Promise((resolve, reject) => {
    Modal.confirm({
      title: option.title || "系统通知",
      icon: createVNode(InfoCircleFilled),
      content: option.content,
      okText: "确定",
      cancelText: "取消",
      onOk() {
        resolve("confirm");
      },
      onCancel() {
        reject();
      },
    });
  });
}
