import React, { ReactNode } from 'react'; import { Modal, ModalProps } from 'antd'; import { QuestionCircleOutlined } from '@ant-design/icons'; export interface confirmOptions extends ModalProps { title?: string, color?: string, content?: string | ReactNode, } /** * promise confirm * @param options * @returns {Promise} */ export default async function confirm(options: string | confirmOptions) { if (typeof options === 'string') { // eslint-disable-next-line no-param-reassign options = { content: options, }; } const { title = '温馨提示', content, color = 'red', ...others } = options; return new Promise((resolve, reject) => { Modal.confirm({ icon: , title, content:
{content}
, okText: '确定', cancelText: '取消', onOk: () => resolve(), onCancel: () => reject(), ...others, }); }); }