message-verify 0.0.41-beta.0 → 0.0.42-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 +4 -6
- package/dist/index.js +4 -4
- package/dist/main.js +6 -6
- package/dist/verify-modal.d.ts +5 -7
- package/dist/verify-modal.js +11 -5
- package/package.json +1 -1
- package/src/index.tsx +8 -10
- package/src/main.tsx +6 -6
- package/src/verify-modal.tsx +15 -11
package/dist/index.d.ts
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
export type ModalConfig = {
|
2
|
-
data:
|
3
|
-
mobile: string;
|
4
|
-
verifyCodeKey: string;
|
5
|
-
sendSuccess: boolean;
|
6
|
-
};
|
2
|
+
data: string;
|
7
3
|
onClose?: () => void;
|
4
|
+
config: object;
|
5
|
+
http: (params: object) => Promise<unknown>;
|
8
6
|
};
|
9
|
-
export declare const createMessageVerifyModal: (
|
7
|
+
export declare const createMessageVerifyModal: (modalProps: ModalConfig) => void;
|
package/dist/index.js
CHANGED
@@ -2,15 +2,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import ReactDOM from 'react-dom/client';
|
3
3
|
import VerifyModal from './verify-modal.js';
|
4
4
|
let modalRoot = null;
|
5
|
-
export const createMessageVerifyModal = (
|
5
|
+
export const createMessageVerifyModal = (modalProps) => {
|
6
6
|
const container = document.createElement('div');
|
7
7
|
container.id = 'antd-modal-container';
|
8
8
|
document.body.appendChild(container);
|
9
9
|
modalRoot = ReactDOM.createRoot(container);
|
10
|
-
modalRoot.render(_jsx(VerifyModal, {
|
11
|
-
...
|
10
|
+
modalRoot.render(_jsx(VerifyModal, { props: {
|
11
|
+
...modalProps,
|
12
12
|
onClose: () => {
|
13
|
-
|
13
|
+
modalProps.onClose?.();
|
14
14
|
destroyModal();
|
15
15
|
}
|
16
16
|
} }));
|
package/dist/main.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
import { createRoot } from 'react-dom/client';
|
3
3
|
import { createMessageVerifyModal } from './index.js'; // 或 './index'
|
4
|
-
const data = {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
9
|
-
|
4
|
+
const data = "{\"mobile\":\"188****4035\",\"verifyCodeKey\":\"3f025b33-988e-47c0-950d-6beb776d043f\",\"needValid\":true,\"step\":2,\"message\":\"需要填写验证码\"}";
|
5
|
+
createRoot(document.getElementById('root')).render(_jsx("button", { onClick: () => createMessageVerifyModal({
|
6
|
+
data,
|
7
|
+
config: {},
|
8
|
+
http: () => Promise.resolve({}),
|
9
|
+
}), children: "Show Modal" }));
|
package/dist/verify-modal.d.ts
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
type ModalConfig = {
|
2
|
-
data:
|
3
|
-
mobile: string;
|
4
|
-
verifyCodeKey: string;
|
5
|
-
sendSuccess: boolean;
|
6
|
-
};
|
2
|
+
data: string;
|
7
3
|
onClose?: () => void;
|
4
|
+
config: object;
|
5
|
+
http: (params: object) => Promise<unknown>;
|
8
6
|
};
|
9
|
-
declare const ModalDom: ({
|
10
|
-
|
7
|
+
declare const ModalDom: ({ props }: {
|
8
|
+
props: ModalConfig;
|
11
9
|
}) => import("react/jsx-runtime.js").JSX.Element;
|
12
10
|
export default ModalDom;
|
package/dist/verify-modal.js
CHANGED
@@ -2,14 +2,15 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from 'react';
|
3
3
|
import { Modal, Input, Button, message } from './compoments/index.js';
|
4
4
|
import Api from './resource.js';
|
5
|
-
const ModalDom = ({
|
5
|
+
const ModalDom = ({ props }) => {
|
6
6
|
const [visible, setVisible] = useState(true);
|
7
7
|
const [countdown, setCountdown] = useState(3);
|
8
8
|
const [captchaImage, setCaptchaImage] = useState('');
|
9
9
|
const [captchCode, setCaptchCode] = useState('');
|
10
10
|
const [captchaKey, setCaptchaKey] = useState('');
|
11
|
-
const { data } =
|
12
|
-
const
|
11
|
+
const { data, config, http } = props || {};
|
12
|
+
const dataObj = JSON.parse(data || '{}');
|
13
|
+
const { mobile } = dataObj || {};
|
13
14
|
const getKey = async () => {
|
14
15
|
const res = await Api.getCaptchaKey();
|
15
16
|
const { body: key } = res.data || {};
|
@@ -47,9 +48,14 @@ const ModalDom = ({ config }) => {
|
|
47
48
|
};
|
48
49
|
return (_jsxs(Modal, { visible: visible, onClose: () => {
|
49
50
|
setVisible(false);
|
50
|
-
|
51
|
+
props.onClose?.();
|
51
52
|
}, children: [_jsxs("div", { style: { fontSize: 14, color: '#666' }, children: ["\u5DF2\u53D1\u9001\u77ED\u4FE1\u81F3\u60A8\u7684\u624B\u673A\uFF1A", mobile] }), countdown > 0 ? null : _jsxs("div", { style: { marginBlock: 8, display: 'flex', alignItems: 'center', width: 300 }, children: [_jsx(Input, { placeholder: "\u8BF7\u8F93\u5165\u56FE\u5F62\u9A8C\u8BC1\u7801", onChange: (e) => {
|
52
53
|
setCaptchCode(e);
|
53
|
-
} }), captchaImage && _jsx("img", { src: captchaImage, alt: "\u9A8C\u8BC1\u7801", style: { width: 100, height: 30, marginLeft: 8 }, onClick: getKey })] }), (countdown > 0 || captchCode) ? null : _jsx("div", { style: { fontSize: 14, color: 'red' }, children: "\u8BF7\u8F93\u5165\u56FE\u5F62\u9A8C\u8BC1\u7801\u540E\uFF0C\u91CD\u65B0\u53D1\u9001\u9A8C\u8BC1\u7801" }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }, children: [_jsx(Input, { placeholder: "\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801", onChange: (val) => {
|
54
|
+
} }), captchaImage && _jsx("img", { src: captchaImage, alt: "\u9A8C\u8BC1\u7801", style: { width: 100, height: 30, marginLeft: 8 }, onClick: getKey })] }), (countdown > 0 || captchCode) ? null : _jsx("div", { style: { fontSize: 14, color: 'red' }, children: "\u8BF7\u8F93\u5165\u56FE\u5F62\u9A8C\u8BC1\u7801\u540E\uFF0C\u91CD\u65B0\u53D1\u9001\u9A8C\u8BC1\u7801" }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }, children: [_jsx(Input, { placeholder: "\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801", onChange: (val) => {
|
55
|
+
if (val.length === 6) {
|
56
|
+
console.log('change', val.length);
|
57
|
+
http(config);
|
58
|
+
}
|
59
|
+
} }), _jsx(Button, { disabled: countdown > 0 || !captchCode, onClick: handleResend, children: countdown > 0 ? `${countdown}秒` : '重新发送' })] })] }));
|
54
60
|
};
|
55
61
|
export default ModalDom;
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
@@ -2,17 +2,15 @@ import ReactDOM from 'react-dom/client'
|
|
2
2
|
import VerifyModal from './verify-modal.js'
|
3
3
|
|
4
4
|
export type ModalConfig = {
|
5
|
-
data:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
};
|
10
|
-
onClose?: () => void
|
5
|
+
data: string;
|
6
|
+
onClose?: () => void
|
7
|
+
config: object;
|
8
|
+
http: (params: object) => Promise<unknown>;
|
11
9
|
}
|
12
10
|
|
13
11
|
let modalRoot: ReactDOM.Root | null = null
|
14
12
|
|
15
|
-
export const createMessageVerifyModal = (
|
13
|
+
export const createMessageVerifyModal = (modalProps: ModalConfig) => {
|
16
14
|
const container = document.createElement('div')
|
17
15
|
container.id = 'antd-modal-container'
|
18
16
|
document.body.appendChild(container)
|
@@ -20,10 +18,10 @@ export const createMessageVerifyModal = (config: ModalConfig) => {
|
|
20
18
|
modalRoot = ReactDOM.createRoot(container)
|
21
19
|
modalRoot.render(
|
22
20
|
<VerifyModal
|
23
|
-
|
24
|
-
...
|
21
|
+
props={{
|
22
|
+
...modalProps,
|
25
23
|
onClose: () => {
|
26
|
-
|
24
|
+
modalProps.onClose?.()
|
27
25
|
destroyModal()
|
28
26
|
}
|
29
27
|
}}
|
package/src/main.tsx
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
import { createRoot } from 'react-dom/client';
|
2
2
|
import { createMessageVerifyModal } from './index.js'; // 或 './index'
|
3
3
|
|
4
|
-
const data = {
|
5
|
-
mobile: '185****7760',
|
6
|
-
verifyCodeKey: 'e381c5f9-c7f4-4bf1-a948-744334fb0203',
|
7
|
-
sendSuccess: true
|
8
|
-
}
|
4
|
+
const data = "{\"mobile\":\"188****4035\",\"verifyCodeKey\":\"3f025b33-988e-47c0-950d-6beb776d043f\",\"needValid\":true,\"step\":2,\"message\":\"需要填写验证码\"}";
|
9
5
|
|
10
6
|
createRoot(document.getElementById('root')!).render(
|
11
|
-
<button onClick={() => createMessageVerifyModal({
|
7
|
+
<button onClick={() => createMessageVerifyModal({
|
8
|
+
data,
|
9
|
+
config: {},
|
10
|
+
http: () => Promise.resolve({}),
|
11
|
+
})}>
|
12
12
|
Show Modal
|
13
13
|
</button>);
|
package/src/verify-modal.tsx
CHANGED
@@ -3,21 +3,20 @@ import { Modal, Input, Button, message } from './compoments/index.js'
|
|
3
3
|
import Api from './resource.js'
|
4
4
|
|
5
5
|
type ModalConfig = {
|
6
|
-
data:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
};
|
11
|
-
onClose?: () => void
|
6
|
+
data: string;
|
7
|
+
onClose?: () => void;
|
8
|
+
config: object;
|
9
|
+
http: (params: object) => Promise<unknown>;
|
12
10
|
}
|
13
|
-
const ModalDom = ({
|
11
|
+
const ModalDom = ({ props }: { props: ModalConfig }) => {
|
14
12
|
const [visible, setVisible] = useState(true);
|
15
13
|
const [countdown, setCountdown] = useState(3);
|
16
14
|
const [captchaImage, setCaptchaImage] = useState<string>('');
|
17
15
|
const [captchCode, setCaptchCode] = useState<string>('');
|
18
16
|
const [captchaKey, setCaptchaKey] = useState<string>('');
|
19
|
-
const { data } =
|
20
|
-
const
|
17
|
+
const { data, config, http } = props || {};
|
18
|
+
const dataObj = JSON.parse(data || '{}');
|
19
|
+
const { mobile } = dataObj || {};
|
21
20
|
|
22
21
|
|
23
22
|
const getKey = async () => {
|
@@ -63,7 +62,7 @@ const ModalDom = ({ config }: { config: ModalConfig }) => {
|
|
63
62
|
visible={visible}
|
64
63
|
onClose={() => {
|
65
64
|
setVisible(false);
|
66
|
-
|
65
|
+
props.onClose?.();
|
67
66
|
}}
|
68
67
|
>
|
69
68
|
<div style={{ fontSize: 14, color: '#666' }}>已发送短信至您的手机:{mobile}</div>
|
@@ -81,7 +80,12 @@ const ModalDom = ({ config }: { config: ModalConfig }) => {
|
|
81
80
|
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }}>
|
82
81
|
<Input
|
83
82
|
placeholder="请输入验证码"
|
84
|
-
onChange={(val) => {
|
83
|
+
onChange={(val) => {
|
84
|
+
if(val.length === 6) {
|
85
|
+
console.log('change', val.length)
|
86
|
+
http(config);
|
87
|
+
}
|
88
|
+
}}
|
85
89
|
/>
|
86
90
|
<Button
|
87
91
|
disabled={countdown > 0 || !captchCode}
|