message-verify 0.0.30-beta.0 → 0.0.31-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export type ModalConfig = {
2
2
  content: React.ReactNode;
3
+ title?: string;
4
+ width?: number;
3
5
  onClose?: () => void;
4
6
  };
5
7
  export declare const showModal: (config: ModalConfig) => void;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // import App from './app.js';
3
3
  // import { createRoot } from 'react-dom/client';
4
4
  // interface Props {
@@ -29,25 +29,28 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
29
29
  // export { createMessageVerify };
30
30
  // export default createMessageVerify;
31
31
  // src/modal.tsx
32
+ // src/modal.tsx
33
+ import { Modal } from 'antd';
32
34
  import ReactDOM from 'react-dom/client';
33
35
  let modalRoot = null;
34
- const Modal = ({ content, onClose }) => (_jsx("div", { className: "modal-overlay", children: _jsxs("div", { className: "modal-content", children: [content, _jsx("button", { onClick: onClose, children: "Close" })] }) }));
36
+ const AntdModal = ({ config }) => (_jsx(Modal, { open: true, title: config.title || '提示', width: config.width || 600, onCancel: config.onClose, footer: null, children: config.content }));
35
37
  export const showModal = (config) => {
36
- // 创建容器
37
38
  const container = document.createElement('div');
38
- container.id = 'global-modal-container';
39
+ container.id = 'antd-modal-container';
39
40
  document.body.appendChild(container);
40
- // 渲染弹窗
41
41
  modalRoot = ReactDOM.createRoot(container);
42
- modalRoot.render(_jsx(Modal, { ...config, onClose: () => {
43
- config.onClose?.();
44
- destroyModal();
42
+ modalRoot.render(_jsx(AntdModal, { config: {
43
+ ...config,
44
+ onClose: () => {
45
+ config.onClose?.();
46
+ destroyModal();
47
+ }
45
48
  } }));
46
49
  };
47
50
  const destroyModal = () => {
48
51
  if (modalRoot) {
49
52
  modalRoot.unmount();
50
- document.getElementById('global-modal-container')?.remove();
53
+ document.getElementById('antd-modal-container')?.remove();
51
54
  modalRoot = null;
52
55
  }
53
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "message-verify",
3
- "version": "0.0.30-beta.0",
3
+ "version": "0.0.31-beta.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
package/src/index.tsx CHANGED
@@ -33,38 +33,45 @@
33
33
  // export { createMessageVerify };
34
34
  // export default createMessageVerify;
35
35
  // src/modal.tsx
36
+ // src/modal.tsx
37
+ import { Modal } from 'antd'
36
38
  import ReactDOM from 'react-dom/client'
37
39
 
38
40
  export type ModalConfig = {
39
41
  content: React.ReactNode
42
+ title?: string
43
+ width?: number
40
44
  onClose?: () => void
41
45
  }
42
46
 
43
47
  let modalRoot: ReactDOM.Root | null = null
44
48
 
45
- const Modal = ({ content, onClose }: ModalConfig) => (
46
- <div className="modal-overlay">
47
- <div className="modal-content">
48
- {content}
49
- <button onClick={onClose}>Close</button>
50
- </div>
51
- </div>
49
+ const AntdModal = ({ config }: { config: ModalConfig }) => (
50
+ <Modal
51
+ open={true}
52
+ title={config.title || '提示'}
53
+ width={config.width || 600}
54
+ onCancel={config.onClose}
55
+ footer={null}
56
+ >
57
+ {config.content}
58
+ </Modal>
52
59
  )
53
60
 
54
61
  export const showModal = (config: ModalConfig) => {
55
- // 创建容器
56
62
  const container = document.createElement('div')
57
- container.id = 'global-modal-container'
63
+ container.id = 'antd-modal-container'
58
64
  document.body.appendChild(container)
59
65
 
60
- // 渲染弹窗
61
66
  modalRoot = ReactDOM.createRoot(container)
62
67
  modalRoot.render(
63
- <Modal
64
- {...config}
65
- onClose={() => {
66
- config.onClose?.()
67
- destroyModal()
68
+ <AntdModal
69
+ config={{
70
+ ...config,
71
+ onClose: () => {
72
+ config.onClose?.()
73
+ destroyModal()
74
+ }
68
75
  }}
69
76
  />
70
77
  )
@@ -73,7 +80,7 @@ export const showModal = (config: ModalConfig) => {
73
80
  const destroyModal = () => {
74
81
  if (modalRoot) {
75
82
  modalRoot.unmount()
76
- document.getElementById('global-modal-container')?.remove()
83
+ document.getElementById('antd-modal-container')?.remove()
77
84
  modalRoot = null
78
85
  }
79
86
  }