index.js 955 B

123456789101112131415161718192021222324252627282930313233343536
  1. import Modal from './Modal';
  2. import confirm, { withWarn, withInfo, withSuccess, withError, withConfirm } from './confirm';
  3. import useModal from './useModal';
  4. import destroyFns from './destroyFns';
  5. function modalWarn(props) {
  6. return confirm(withWarn(props));
  7. }
  8. Modal.useModal = useModal;
  9. Modal.info = function infoFn(props) {
  10. return confirm(withInfo(props));
  11. };
  12. Modal.success = function successFn(props) {
  13. return confirm(withSuccess(props));
  14. };
  15. Modal.error = function errorFn(props) {
  16. return confirm(withError(props));
  17. };
  18. Modal.warning = modalWarn;
  19. Modal.warn = modalWarn;
  20. Modal.confirm = function confirmFn(props) {
  21. return confirm(withConfirm(props));
  22. };
  23. Modal.destroyAll = function destroyAllFn() {
  24. while (destroyFns.length) {
  25. const close = destroyFns.pop();
  26. if (close) {
  27. close();
  28. }
  29. }
  30. };
  31. /* istanbul ignore next */
  32. Modal.install = function (app) {
  33. app.component(Modal.name, Modal);
  34. return app;
  35. };
  36. export default Modal;