message-verify 0.0.29-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,14 +1,7 @@
1
- interface Props {
2
- data: {
3
- mobile: string;
4
- verifyCodeKey: string;
5
- sendSuccess: boolean;
6
- };
7
- refresh: () => void;
8
- isShow: boolean;
9
- }
10
- declare function createMessageVerify(props: Props): {
11
- destroy: () => void;
1
+ export type ModalConfig = {
2
+ content: React.ReactNode;
3
+ title?: string;
4
+ width?: number;
5
+ onClose?: () => void;
12
6
  };
13
- export { createMessageVerify };
14
- export default createMessageVerify;
7
+ export declare const showModal: (config: ModalConfig) => void;
package/dist/index.js CHANGED
@@ -1,21 +1,56 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import App from './app.js';
3
- import { createRoot } from 'react-dom/client';
4
- function createMessageVerify(props) {
5
- // 创建一个挂载点
2
+ // import App from './app.js';
3
+ // import { createRoot } from 'react-dom/client';
4
+ // interface Props {
5
+ // data: {
6
+ // mobile: string;
7
+ // verifyCodeKey: string;
8
+ // sendSuccess: boolean;
9
+ // };
10
+ // refresh: () => void;
11
+ // isShow: boolean;
12
+ // }
13
+ // function createMessageVerify(props: Props) {
14
+ // // 创建一个挂载点
15
+ // const container = document.createElement('div');
16
+ // document.body.appendChild(container);
17
+ // // 渲染弹窗
18
+ // const root = createRoot(container);
19
+ // // 这里 isShow 直接传 true,弹窗立即显示
20
+ // root.render(<App {...props} isShow={true} />);
21
+ // // 可选:返回关闭方法
22
+ // return {
23
+ // destroy: () => {
24
+ // root.unmount();
25
+ // document.body.removeChild(container);
26
+ // }
27
+ // };
28
+ // }
29
+ // export { createMessageVerify };
30
+ // export default createMessageVerify;
31
+ // src/modal.tsx
32
+ // src/modal.tsx
33
+ import { Modal } from 'antd';
34
+ import ReactDOM from 'react-dom/client';
35
+ let modalRoot = null;
36
+ const AntdModal = ({ config }) => (_jsx(Modal, { open: true, title: config.title || '提示', width: config.width || 600, onCancel: config.onClose, footer: null, children: config.content }));
37
+ export const showModal = (config) => {
6
38
  const container = document.createElement('div');
39
+ container.id = 'antd-modal-container';
7
40
  document.body.appendChild(container);
8
- // 渲染弹窗
9
- const root = createRoot(container);
10
- // 这里 isShow 直接传 true,弹窗立即显示
11
- root.render(_jsx(App, { ...props, isShow: true }));
12
- // 可选:返回关闭方法
13
- return {
14
- destroy: () => {
15
- root.unmount();
16
- document.body.removeChild(container);
17
- }
18
- };
19
- }
20
- export { createMessageVerify };
21
- export default createMessageVerify;
41
+ modalRoot = ReactDOM.createRoot(container);
42
+ modalRoot.render(_jsx(AntdModal, { config: {
43
+ ...config,
44
+ onClose: () => {
45
+ config.onClose?.();
46
+ destroyModal();
47
+ }
48
+ } }));
49
+ };
50
+ const destroyModal = () => {
51
+ if (modalRoot) {
52
+ modalRoot.unmount();
53
+ document.getElementById('antd-modal-container')?.remove();
54
+ modalRoot = null;
55
+ }
56
+ };
package/dist/main.js CHANGED
@@ -1,8 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createRoot } from 'react-dom/client';
3
- import App from './app.js'; // 或 './index'
4
- createRoot(document.getElementById('root')).render(_jsx(App, { data: {
5
- mobile: '185****7760',
6
- verifyCodeKey: 'e381c5f9-c7f4-4bf1-a948-744334fb0203',
7
- sendSuccess: true
8
- }, refresh: () => { console.log('刷新'); }, isShow: true }));
3
+ import { showModal } from './index.js'; // 或 './index'
4
+ createRoot(document.getElementById('root')).render(_jsx("button", { onClick: () => showModal({ content: 'React Content' }), children: "Show Modal" }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "message-verify",
3
- "version": "0.0.29-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
@@ -1,34 +1,86 @@
1
- import App from './app.js';
2
- import { createRoot } from 'react-dom/client';
3
-
4
- interface Props {
5
- data: {
6
- mobile: string;
7
- verifyCodeKey: string;
8
- sendSuccess: boolean;
9
- };
10
- refresh: () => void;
11
- isShow: boolean;
1
+ // import App from './app.js';
2
+ // import { createRoot } from 'react-dom/client';
3
+
4
+ // interface Props {
5
+ // data: {
6
+ // mobile: string;
7
+ // verifyCodeKey: string;
8
+ // sendSuccess: boolean;
9
+ // };
10
+ // refresh: () => void;
11
+ // isShow: boolean;
12
+ // }
13
+
14
+ // function createMessageVerify(props: Props) {
15
+ // // 创建一个挂载点
16
+ // const container = document.createElement('div');
17
+ // document.body.appendChild(container);
18
+
19
+ // // 渲染弹窗
20
+ // const root = createRoot(container);
21
+ // // 这里 isShow 直接传 true,弹窗立即显示
22
+ // root.render(<App {...props} isShow={true} />);
23
+
24
+ // // 可选:返回关闭方法
25
+ // return {
26
+ // destroy: () => {
27
+ // root.unmount();
28
+ // document.body.removeChild(container);
29
+ // }
30
+ // };
31
+ // }
32
+
33
+ // export { createMessageVerify };
34
+ // export default createMessageVerify;
35
+ // src/modal.tsx
36
+ // src/modal.tsx
37
+ import { Modal } from 'antd'
38
+ import ReactDOM from 'react-dom/client'
39
+
40
+ export type ModalConfig = {
41
+ content: React.ReactNode
42
+ title?: string
43
+ width?: number
44
+ onClose?: () => void
12
45
  }
13
46
 
14
- function createMessageVerify(props: Props) {
15
- // 创建一个挂载点
16
- const container = document.createElement('div');
17
- document.body.appendChild(container);
18
-
19
- // 渲染弹窗
20
- const root = createRoot(container);
21
- // 这里 isShow 直接传 true,弹窗立即显示
22
- root.render(<App {...props} isShow={true} />);
23
-
24
- // 可选:返回关闭方法
25
- return {
26
- destroy: () => {
27
- root.unmount();
28
- document.body.removeChild(container);
47
+ let modalRoot: ReactDOM.Root | null = null
48
+
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>
59
+ )
60
+
61
+ export const showModal = (config: ModalConfig) => {
62
+ const container = document.createElement('div')
63
+ container.id = 'antd-modal-container'
64
+ document.body.appendChild(container)
65
+
66
+ modalRoot = ReactDOM.createRoot(container)
67
+ modalRoot.render(
68
+ <AntdModal
69
+ config={{
70
+ ...config,
71
+ onClose: () => {
72
+ config.onClose?.()
73
+ destroyModal()
29
74
  }
30
- };
75
+ }}
76
+ />
77
+ )
31
78
  }
32
79
 
33
- export { createMessageVerify };
34
- export default createMessageVerify;
80
+ const destroyModal = () => {
81
+ if (modalRoot) {
82
+ modalRoot.unmount()
83
+ document.getElementById('antd-modal-container')?.remove()
84
+ modalRoot = null
85
+ }
86
+ }
package/src/main.tsx CHANGED
@@ -1,13 +1,7 @@
1
1
  import { createRoot } from 'react-dom/client';
2
- import App from './app.js'; // 或 './index'
2
+ import { showModal } from './index.js'; // 或 './index'
3
3
 
4
4
  createRoot(document.getElementById('root')!).render(
5
- <App
6
- data={{
7
- mobile: '185****7760',
8
- verifyCodeKey: 'e381c5f9-c7f4-4bf1-a948-744334fb0203',
9
- sendSuccess: true
10
- }}
11
- refresh={() => {console.log('刷新')}}
12
- isShow={true}
13
- />);
5
+ <button onClick={() => showModal({ content: 'React Content' })}>
6
+ Show Modal
7
+ </button>);