2021-06-26 01:35:40 +00:00
|
|
|
import type { App, Plugin } from 'vue';
|
|
|
|
import type { ModalFunc, ModalFuncProps } from './Modal';
|
|
|
|
import Modal, { destroyFns } from './Modal';
|
2019-01-12 03:33:27 +00:00
|
|
|
import modalConfirm from './confirm';
|
2020-03-24 08:58:53 +00:00
|
|
|
import InfoCircleOutlined from '@ant-design/icons-vue/InfoCircleOutlined';
|
|
|
|
import CheckCircleOutlined from '@ant-design/icons-vue/CheckCircleOutlined';
|
|
|
|
import CloseCircleOutlined from '@ant-design/icons-vue/CloseCircleOutlined';
|
|
|
|
import ExclamationCircleOutlined from '@ant-design/icons-vue/ExclamationCircleOutlined';
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2021-09-25 08:51:32 +00:00
|
|
|
export type { IActionButtonProps as ActionButtonProps } from './ActionButton';
|
|
|
|
export type { ModalProps, ModalFuncProps } from './Modal';
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2021-06-23 15:08:16 +00:00
|
|
|
const info = function (props: ModalFuncProps) {
|
2018-03-06 11:14:41 +00:00
|
|
|
const config = {
|
|
|
|
type: 'info',
|
2021-09-08 09:12:11 +00:00
|
|
|
icon: () => <InfoCircleOutlined />,
|
2018-03-06 11:14:41 +00:00
|
|
|
okCancel: false,
|
|
|
|
...props,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
return modalConfirm(config);
|
|
|
|
};
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2021-06-23 15:08:16 +00:00
|
|
|
const success = function (props: ModalFuncProps) {
|
2018-03-06 11:14:41 +00:00
|
|
|
const config = {
|
|
|
|
type: 'success',
|
2021-09-08 09:12:11 +00:00
|
|
|
icon: () => <CheckCircleOutlined />,
|
2018-03-06 11:14:41 +00:00
|
|
|
okCancel: false,
|
|
|
|
...props,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
return modalConfirm(config);
|
|
|
|
};
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2021-06-23 15:08:16 +00:00
|
|
|
const error = function (props: ModalFuncProps) {
|
2018-03-06 11:14:41 +00:00
|
|
|
const config = {
|
|
|
|
type: 'error',
|
2021-09-08 09:12:11 +00:00
|
|
|
icon: () => <CloseCircleOutlined />,
|
2018-03-06 11:14:41 +00:00
|
|
|
okCancel: false,
|
|
|
|
...props,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
return modalConfirm(config);
|
|
|
|
};
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2021-06-23 15:08:16 +00:00
|
|
|
const warning = function (props: ModalFuncProps) {
|
2018-03-06 11:14:41 +00:00
|
|
|
const config = {
|
|
|
|
type: 'warning',
|
2021-09-08 09:12:11 +00:00
|
|
|
icon: () => <ExclamationCircleOutlined />,
|
2018-03-06 11:14:41 +00:00
|
|
|
okCancel: false,
|
|
|
|
...props,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
return modalConfirm(config);
|
|
|
|
};
|
|
|
|
const warn = warning;
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2020-10-19 15:09:36 +00:00
|
|
|
const confirm = function confirmFn(props: ModalFuncProps) {
|
2018-03-06 11:14:41 +00:00
|
|
|
const config = {
|
|
|
|
type: 'confirm',
|
|
|
|
okCancel: true,
|
|
|
|
...props,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
return modalConfirm(config);
|
|
|
|
};
|
|
|
|
Modal.info = info;
|
|
|
|
Modal.success = success;
|
|
|
|
Modal.error = error;
|
|
|
|
Modal.warning = warning;
|
|
|
|
Modal.warn = warn;
|
|
|
|
Modal.confirm = confirm;
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2020-03-07 11:45:13 +00:00
|
|
|
Modal.destroyAll = function destroyAllFn() {
|
2019-04-17 02:21:28 +00:00
|
|
|
while (destroyFns.length) {
|
|
|
|
const close = destroyFns.pop();
|
|
|
|
if (close) {
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-09-19 05:21:57 +00:00
|
|
|
/* istanbul ignore next */
|
2021-06-23 15:08:16 +00:00
|
|
|
Modal.install = function (app: App) {
|
2020-06-15 15:47:49 +00:00
|
|
|
app.component(Modal.name, Modal);
|
2020-10-13 11:14:56 +00:00
|
|
|
return app;
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-09-19 05:21:57 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
export default Modal as typeof Modal &
|
|
|
|
Plugin & {
|
|
|
|
readonly info: ModalFunc;
|
2020-10-21 07:32:04 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
readonly success: ModalFunc;
|
2020-10-21 07:32:04 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
readonly error: ModalFunc;
|
2020-10-21 07:32:04 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
readonly warn: ModalFunc;
|
2020-10-21 07:32:04 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
readonly warning: ModalFunc;
|
2020-10-21 07:32:04 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
readonly confirm: ModalFunc;
|
2020-10-21 07:32:04 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
readonly destroyAll: () => void;
|
|
|
|
};
|