f_000006 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. import { createHotContext as __vite__createHotContext } from "/@vite/client";import.meta.hot = __vite__createHotContext("/src/components/Provider/Modal.tsx");import { mergeProps as _mergeProps, createVNode as _createVNode, Fragment as _Fragment } from "/node_modules/.vite/deps/vue.js?v=3bf0172c";
  2. import { Modal as AntdModal } from "/node_modules/.vite/deps/ant-design-vue.js?v=f7d2fa05";
  3. import { CloseOutlined } from "/node_modules/.vite/deps/@ant-design_icons-vue.js?v=2150c144";
  4. import { defineComponent, inject, onBeforeUnmount, onMounted, provide, reactive, ref } from "/node_modules/.vite/deps/vue.js?v=3bf0172c";
  5. import { bool, number } from "/node_modules/.vite/deps/vue-types.js?v=3b44f7bd";
  6. import { useRouter } from "/node_modules/.vite/deps/vue-router.js?v=0a002a54";
  7. import "/src/components/Provider/Modal.less";
  8. import ModalConfirm from "/src/components/Provider/ModalConfirm.tsx";
  9. import ModalInput from "/src/components/Provider/ModalInput.tsx";
  10. const store = reactive({
  11. modalKeys: [],
  12. modalMaps: /* @__PURE__ */new Map()
  13. });
  14. const MyModal = defineComponent({
  15. props: {
  16. visible: bool().isRequired,
  17. modalKey: number().isRequired
  18. },
  19. setup(props) {
  20. provide("modalContext", props.modalKey);
  21. const closeRef = ref();
  22. const {
  23. context,
  24. children,
  25. closable,
  26. title,
  27. fullscreen,
  28. width,
  29. ...otherProps
  30. } = store.modalMaps.get(props.modalKey);
  31. const baseProps = {
  32. width,
  33. closable
  34. };
  35. const isSelfWidth = !(width && !fullscreen);
  36. if (context) {
  37. Object.entries(context).forEach(([key, value]) => {
  38. provide(key, value);
  39. });
  40. }
  41. if (isSelfWidth) {
  42. baseProps.closable = false;
  43. baseProps.width = "auto";
  44. baseProps.class = "inf-modal" + (fullscreen ? " ant-modal-fullscreen" : "");
  45. onMounted(() => {
  46. const closeEl = closeRef.value;
  47. if (closeEl) {
  48. const maskEl = closeEl.parentElement.parentElement;
  49. }
  50. });
  51. onBeforeUnmount(() => {
  52. const closeEl = closeRef.value;
  53. if (closeEl) {
  54. const maskEl = closeEl.parentElement.parentElement;
  55. maskEl.removeEventListener("click", closeModal);
  56. }
  57. });
  58. } else {
  59. baseProps.title = title;
  60. }
  61. function closeModal(e) {
  62. if (e.target === e.currentTarget) {
  63. otherProps.onCancel?.();
  64. }
  65. }
  66. const RenderSelfHeader = () => _createVNode(_Fragment, null, [closable ? _createVNode(CloseOutlined, {
  67. "class": "ant-modal-close",
  68. "onClick": () => otherProps.onCancel(),
  69. "ref": closeRef
  70. }, null) : null, title ? _createVNode("div", {
  71. "class": "ant-modal-header"
  72. }, [title]) : null]);
  73. return () => {
  74. return _createVNode(AntdModal, _mergeProps({
  75. "key": props.modalKey,
  76. "visible": props.visible,
  77. "footer": null
  78. }, baseProps, otherProps), {
  79. default: () => [isSelfWidth ? RenderSelfHeader() : null, children]
  80. });
  81. };
  82. }
  83. });
  84. function hidden(key) {
  85. if (key) {
  86. const modal = store.modalKeys.find(item => item.key === key);
  87. modal && (modal.visible = false);
  88. }
  89. }
  90. const Modal = {
  91. show(children, config, context) {
  92. return new Promise((resolve, reject) => {
  93. const key = Date.now();
  94. const {
  95. afterClose,
  96. ...otherConfig
  97. } = config || {};
  98. store.modalMaps.set(key, {
  99. context,
  100. children,
  101. closable: true,
  102. afterClose: () => {
  103. const itemIndex = store.modalKeys.findIndex(item => item.key === key);
  104. if (itemIndex != -1) {
  105. store.modalKeys.splice(itemIndex, 1);
  106. store.modalMaps.delete(key);
  107. }
  108. afterClose?.();
  109. },
  110. ...otherConfig,
  111. onOk: async value => {
  112. if (otherConfig.onOk) {
  113. await otherConfig.onOk(value);
  114. }
  115. resolve(value);
  116. hidden(key);
  117. },
  118. onCancel: msg => {
  119. reject(console.warn(msg));
  120. hidden(key);
  121. }
  122. });
  123. store.modalKeys.push({
  124. key,
  125. visible: true
  126. });
  127. });
  128. },
  129. use() {
  130. const key = inject("modalContext");
  131. const ctx = store.modalMaps.get(key);
  132. return {
  133. submit: ctx.onOk,
  134. cancel: ctx.onCancel
  135. };
  136. },
  137. input(params) {
  138. const {
  139. title,
  140. defaultValue,
  141. placeholder,
  142. maxLength,
  143. okText,
  144. cancelText,
  145. selection,
  146. onValid,
  147. ...otherParams
  148. } = params;
  149. return Modal.show(_createVNode(ModalInput, {
  150. "defaultValue": defaultValue,
  151. "placeholder": placeholder,
  152. "maxLength": maxLength,
  153. "selection": selection,
  154. "okText": okText,
  155. "cancelText": cancelText
  156. }, null), {
  157. width: "400px",
  158. title,
  159. closable: true,
  160. ...otherParams,
  161. onOk: async v => {
  162. const isValid = await (onValid ? onValid(v) : true);
  163. if (isValid) return v;
  164. throw console.warn({
  165. msg: "invalid input value",
  166. silence: true
  167. });
  168. }
  169. });
  170. },
  171. confirm(params) {
  172. const {
  173. type,
  174. okText,
  175. refuseText,
  176. cancelText,
  177. content,
  178. ...otherParams
  179. } = params;
  180. return Modal.show(_createVNode(ModalConfirm, {
  181. "type": type,
  182. "content": content,
  183. "okText": okText,
  184. "refuseText": refuseText,
  185. "cancelText": cancelText
  186. }, null), {
  187. width: "400px",
  188. ...otherParams
  189. });
  190. },
  191. clear() {
  192. store.modalKeys = [];
  193. store.modalMaps.clear();
  194. }
  195. };
  196. export const ModalProvider = defineComponent(() => {
  197. const router = useRouter();
  198. router.beforeEach(() => {
  199. Modal.clear();
  200. });
  201. return () => store.modalKeys.map(({
  202. key,
  203. visible
  204. }) => _createVNode(MyModal, {
  205. "key": key,
  206. "visible": visible,
  207. "modalKey": key
  208. }, null));
  209. });
  210. export default Modal;
  211. ModalProvider.__hmrId = "4070dbe2"
  212. __VUE_HMR_RUNTIME__.createRecord("4070dbe2", ModalProvider)
  213. import.meta.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iAgICAgICAgKSA6IG51bGx9XHJcbiAgICAgICAge3RpdGxlID8gPGRpdiBjbGFzcz1cImFudC1tb2RhbC1oZWFkZXJcIj57dGl0bGV9PC9kaXY+IDogbnVsbH1cclxuICAgICAgPC8+XHJcbiAgICApO1xyXG5cclxuICAgIHJldHVybiAoKSA9PiB7XHJcbiAgICAgIHJldHVybiAoXHJcbiAgICAgICAgPEFudGRNb2RhbFxyXG4gICAgICAgICAga2V5PXtwcm9wcy5tb2RhbEtleX1cclxuICAgICAgICAgIHZpc2libGU9e3Byb3BzLnZpc2libGV9XHJcbiAgICAgICAgICBmb290ZXI9e251bGx9XHJcbiAgICAgICAgICB7Li4uYmFzZVByb3BzfVxyXG4gICAgICAgICAgey4uLm90aGVyUHJvcHN9XHJcbiAgICAgICAgPlxyXG4gICAgICAgICAge2lzU2VsZldpZHRoID8gUmVuZGVyU2VsZkhlYWRlcigpIDogbnVsbH1cclxuICAgICAgICAgIHtjaGlsZHJlbn1cclxuICAgICAgICA8L0FudGRNb2RhbD5cclxuICAgICAgKTtcclxuICAgIH07XHJcbiAgfSxcclxufSk7XHJcblxyXG5mdW5jdGlvbiBoaWRkZW4oa2V5OiBudW1iZXIpIHtcclxuICBpZiAoa2V5KSB7XHJcbiAgICBjb25zdCBtb2RhbCA9IHN0b3JlLm1vZGFsS2V5cy5maW5kKChpdGVtKSA9PiBpdGVtLmtleSA9PT0ga2V5KTtcclxuICAgIG1vZGFsICYmIChtb2RhbC52aXNpYmxlID0gZmFsc2UpO1xyXG4gIH1cclxufVxyXG5cclxuY29uc3QgTW9kYWwgPSB7XHJcbiAgc2hvdyhcclxuICAgIGNoaWxkcmVuOiBKU1guRWxlbWVudCxcclxuICAgIGNvbmZpZz86IHtcclxuICAgICAgd2lkdGg/OiBzdHJpbmc7XHJcbiAgICAgIHRpdGxlPzogc3RyaW5nO1xyXG4gICAgICBhZnRlckNsb3NlPzogVm9pZEZ1bmN0aW9uO1xyXG4gICAgICBjbG9zYWJsZT86IGJvb2xlYW47XHJcbiAgICAgIGZ1bGxzY3JlZW4/OiBib29sZWFuO1xyXG4gICAgICBvbk9rPzogYW55O1xyXG4gICAgICBvbkNhbmNlbD86IGFueTtcclxuICAgICAgW25hbWU6IHN0cmluZ106IGFueTtcclxuICAgIH0sXHJcbiAgICBjb250ZXh0Pzoge1xyXG4gICAgICBbbmFtZTogc3RyaW5nXTogYW55O1xyXG4gICAgfVxyXG4gICkge1xyXG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcclxuICAgICAgY29uc3Qga2V5ID0gRGF0ZS5ub3coKTtcclxuICAgICAgY29uc3QgeyBhZnRlckNsb3NlLCAuLi5vdGhlckNvbmZpZyB9ID0gY29uZmlnIHx8IHt9O1xyXG4gICAgICBzdG9yZS5tb2RhbE1hcHMuc2V0KGtleSwge1xyXG4gICAgICAgIGNvbnRleHQsXHJcbiAgICAgICAgY2hpbGRyZW4sXHJcbiAgICAgICAgY2xvc2FibGU6IHRydWUsXHJcbiAgICAgICAgYWZ0ZXJDbG9zZTogKCkgPT4ge1xyXG4gICAgICAgICAgY29uc3QgaXRlbUluZGV4ID0gc3RvcmUubW9kYWxLZXlzLmZpbmRJbmRleChcclxuICAgICAgICAgICAgKGl0ZW0pID0+IGl0ZW0ua2V5ID09PSBrZXlcclxuICAgICAgICAgICk7XHJcbiAgICAgICAgICBpZiAoaXRlbUluZGV4ICE9IC0xKSB7XHJcbiAgICAgICAgICAgIHN0b3JlLm1vZGFsS2V5cy5zcGxpY2UoaXRlbUluZGV4LCAxKTtcclxuICAgICAgICAgICAgc3RvcmUubW9kYWxNYXBzLmRlbGV0ZShrZXkpO1xyXG4gICAgICAgICAgfVxyXG4gICAgICAgICAgYWZ0ZXJDbG9zZT8uKCk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICAuLi5vdGhlckNvbmZpZyxcclxuICAgICAgICBvbk9rOiBhc3luYyAodmFsdWU/OiBhbnkpID0+IHtcclxuICAg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