message-verify 0.0.33-beta.0 → 0.0.35-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/compoments/button.d.ts +9 -0
- package/dist/compoments/button.js +20 -0
- package/dist/compoments/index.d.ts +4 -0
- package/dist/compoments/index.js +4 -0
- package/dist/compoments/input.d.ts +9 -0
- package/dist/compoments/input.js +13 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +52 -40
- package/dist/main.js +7 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/compoments/button.tsx +38 -0
- package/src/compoments/index.ts +5 -0
- package/src/compoments/input.tsx +30 -0
- package/src/index.tsx +76 -46
- package/src/main.tsx +8 -2
@@ -0,0 +1,9 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
interface CustomButtonProps {
|
3
|
+
disabled?: boolean;
|
4
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
5
|
+
children?: React.ReactNode;
|
6
|
+
style?: React.CSSProperties;
|
7
|
+
}
|
8
|
+
declare const Button: React.FC<CustomButtonProps>;
|
9
|
+
export default Button;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
const Button = ({ disabled, onClick, children, style }) => {
|
3
|
+
const handleClick = (e) => {
|
4
|
+
if (!disabled) {
|
5
|
+
onClick?.(e);
|
6
|
+
// 这里可以记录点击事件
|
7
|
+
console.log('按钮被点击');
|
8
|
+
}
|
9
|
+
};
|
10
|
+
return (_jsx("button", { disabled: disabled, onClick: handleClick, style: {
|
11
|
+
padding: '6px 16px',
|
12
|
+
borderRadius: 4,
|
13
|
+
border: '1px solid #d9d9d9',
|
14
|
+
background: disabled ? '#f5f5f5' : '#1677ff',
|
15
|
+
color: disabled ? '#aaa' : '#fff',
|
16
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
17
|
+
...style,
|
18
|
+
}, children: children }));
|
19
|
+
};
|
20
|
+
export default Button;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
const Input = ({ value, onChange, placeholder, type = 'text' }) => {
|
3
|
+
return (_jsx("input", { type: type, value: value, placeholder: placeholder, onChange: e => onChange?.(e.target.value), style: {
|
4
|
+
padding: '6px 12px',
|
5
|
+
border: '1px solid #d9d9d9',
|
6
|
+
borderRadius: 4,
|
7
|
+
outline: 'none',
|
8
|
+
fontSize: 14,
|
9
|
+
width: '100%',
|
10
|
+
boxSizing: 'border-box'
|
11
|
+
} }));
|
12
|
+
};
|
13
|
+
export default Input;
|
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
export type ModalConfig = {
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
data: {
|
3
|
+
mobile: string;
|
4
|
+
verifyCodeKey: string;
|
5
|
+
sendSuccess: boolean;
|
6
|
+
};
|
5
7
|
onClose?: () => void;
|
6
8
|
};
|
7
|
-
export declare const
|
9
|
+
export declare const createMessageVerifyModal: (config: ModalConfig) => void;
|
package/dist/index.js
CHANGED
@@ -1,54 +1,66 @@
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
-
|
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 './compoments/modal.js';
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Modal, Input, Button } from './compoments/index.js';
|
34
3
|
import ReactDOM from 'react-dom/client';
|
35
|
-
import { useState } from 'react';
|
4
|
+
import { useEffect, useState } from 'react';
|
5
|
+
import Api from './resource.js';
|
36
6
|
let modalRoot = null;
|
37
|
-
|
38
|
-
const AntdModal = ({ config }) => {
|
7
|
+
const ModalDom = ({ config }) => {
|
39
8
|
const [visible, setVisible] = useState(true);
|
40
|
-
|
9
|
+
const [countdown, setCountdown] = useState(60);
|
10
|
+
const [captchaImage, setCaptchaImage] = useState('');
|
11
|
+
const [captchCode, setCaptchCode] = useState('');
|
12
|
+
const [captchaKey, setCaptchaKey] = useState('');
|
13
|
+
const { data } = config || {};
|
14
|
+
const { mobile } = data || {};
|
15
|
+
const getKey = async () => {
|
16
|
+
const res = await Api.getCaptchaKey();
|
17
|
+
const { body: key } = res.data || {};
|
18
|
+
setCaptchaKey(key);
|
19
|
+
if (key) {
|
20
|
+
console.log('res=>key', key);
|
21
|
+
const image = Api.getCaptchaImgUrl(key);
|
22
|
+
console.log('image', image);
|
23
|
+
setCaptchaImage(image);
|
24
|
+
}
|
25
|
+
};
|
26
|
+
useEffect(() => {
|
27
|
+
let timer = null;
|
28
|
+
if (visible && countdown > 0) {
|
29
|
+
timer = setInterval(() => {
|
30
|
+
setCountdown((prev) => prev - 1);
|
31
|
+
}, 1000);
|
32
|
+
}
|
33
|
+
if (countdown === 0) {
|
34
|
+
getKey();
|
35
|
+
}
|
36
|
+
return () => {
|
37
|
+
if (timer)
|
38
|
+
clearInterval(timer);
|
39
|
+
};
|
40
|
+
}, [visible, countdown]);
|
41
|
+
useEffect(() => {
|
42
|
+
console.log('mobile', mobile);
|
43
|
+
}, []);
|
44
|
+
const handleResend = async () => {
|
45
|
+
setCountdown(60);
|
46
|
+
const res = await Api.reSendCode({ captchaKey, captcha: captchCode });
|
47
|
+
console.log('handleResend=>res', res);
|
48
|
+
// message.success('发送成功');
|
49
|
+
};
|
50
|
+
return (_jsxs(Modal, { visible: visible, onClose: () => {
|
41
51
|
setVisible(false);
|
42
52
|
config.onClose?.();
|
43
|
-
}, children:
|
53
|
+
}, children: [_jsxs("div", { children: ["\u5DF2\u53D1\u9001\u77ED\u4FE1\u81F3\u60A8\u7684\u624B\u673A\uFF1A", mobile] }), countdown > 0 ? null : _jsxs("div", { style: { marginTop: 8, display: 'flex', alignItems: 'center', width: 300 }, children: [_jsx(Input, { onChange: (e) => {
|
54
|
+
setCaptchCode(e);
|
55
|
+
} }), captchaImage && _jsx("img", { src: captchaImage, alt: "\u9A8C\u8BC1\u7801", style: { width: 100, height: 30, marginLeft: 8 }, onClick: getKey })] }), countdown > 0 ? null : _jsx("div", { 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, { onChange: (val) => { console.log('change', val); } }), _jsx(Button, { disabled: countdown > 0 || !captchCode, onClick: handleResend, children: countdown > 0 ? `${countdown}秒` : '重新发送' })] })] }));
|
44
56
|
};
|
45
57
|
// ... existing code ...
|
46
|
-
export const
|
58
|
+
export const createMessageVerifyModal = (config) => {
|
47
59
|
const container = document.createElement('div');
|
48
60
|
container.id = 'antd-modal-container';
|
49
61
|
document.body.appendChild(container);
|
50
62
|
modalRoot = ReactDOM.createRoot(container);
|
51
|
-
modalRoot.render(_jsx(
|
63
|
+
modalRoot.render(_jsx(ModalDom, { config: {
|
52
64
|
...config,
|
53
65
|
onClose: () => {
|
54
66
|
config.onClose?.();
|
package/dist/main.js
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
import { createRoot } from 'react-dom/client';
|
3
|
-
import {
|
4
|
-
|
3
|
+
import { createMessageVerifyModal } from './index.js'; // 或 './index'
|
4
|
+
const data = {
|
5
|
+
mobile: '185****7760',
|
6
|
+
verifyCodeKey: 'e381c5f9-c7f4-4bf1-a948-744334fb0203',
|
7
|
+
sendSuccess: true
|
8
|
+
};
|
9
|
+
createRoot(document.getElementById('root')).render(_jsx("button", { onClick: () => createMessageVerifyModal({ data }), children: "Show Modal" }));
|
@@ -1 +1 @@
|
|
1
|
-
{"root":["../src/app.tsx","../src/index.tsx","../src/main.tsx","../src/resource.ts","../src/vite-env.d.ts","../src/compoments/modal.tsx","../src/utils/getfingerprint.ts","../src/utils/index.ts","../src/utils/status.ts"],"version":"5.7.3"}
|
1
|
+
{"root":["../src/app.tsx","../src/index.tsx","../src/main.tsx","../src/resource.ts","../src/vite-env.d.ts","../src/compoments/button.tsx","../src/compoments/index.ts","../src/compoments/input.tsx","../src/compoments/modal.tsx","../src/utils/getfingerprint.ts","../src/utils/index.ts","../src/utils/status.ts"],"version":"5.7.3"}
|
package/package.json
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
|
3
|
+
interface CustomButtonProps {
|
4
|
+
disabled?: boolean;
|
5
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
6
|
+
children?: React.ReactNode;
|
7
|
+
style?: React.CSSProperties;
|
8
|
+
}
|
9
|
+
|
10
|
+
const Button: React.FC<CustomButtonProps> = ({ disabled, onClick, children, style }) => {
|
11
|
+
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
12
|
+
if (!disabled) {
|
13
|
+
onClick?.(e);
|
14
|
+
// 这里可以记录点击事件
|
15
|
+
console.log('按钮被点击');
|
16
|
+
}
|
17
|
+
};
|
18
|
+
|
19
|
+
return (
|
20
|
+
<button
|
21
|
+
disabled={disabled}
|
22
|
+
onClick={handleClick}
|
23
|
+
style={{
|
24
|
+
padding: '6px 16px',
|
25
|
+
borderRadius: 4,
|
26
|
+
border: '1px solid #d9d9d9',
|
27
|
+
background: disabled ? '#f5f5f5' : '#1677ff',
|
28
|
+
color: disabled ? '#aaa' : '#fff',
|
29
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
30
|
+
...style,
|
31
|
+
}}
|
32
|
+
>
|
33
|
+
{children}
|
34
|
+
</button>
|
35
|
+
);
|
36
|
+
};
|
37
|
+
|
38
|
+
export default Button;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
|
3
|
+
interface CustomInputProps {
|
4
|
+
value?: string;
|
5
|
+
onChange?: (val: string) => void;
|
6
|
+
placeholder?: string;
|
7
|
+
type?: string;
|
8
|
+
}
|
9
|
+
|
10
|
+
const Input: React.FC<CustomInputProps> = ({ value, onChange, placeholder, type = 'text' }) => {
|
11
|
+
return (
|
12
|
+
<input
|
13
|
+
type={type}
|
14
|
+
value={value}
|
15
|
+
placeholder={placeholder}
|
16
|
+
onChange={e => onChange?.(e.target.value)}
|
17
|
+
style={{
|
18
|
+
padding: '6px 12px',
|
19
|
+
border: '1px solid #d9d9d9',
|
20
|
+
borderRadius: 4,
|
21
|
+
outline: 'none',
|
22
|
+
fontSize: 14,
|
23
|
+
width: '100%',
|
24
|
+
boxSizing: 'border-box'
|
25
|
+
}}
|
26
|
+
/>
|
27
|
+
);
|
28
|
+
};
|
29
|
+
|
30
|
+
export default Input;
|
package/src/index.tsx
CHANGED
@@ -1,55 +1,66 @@
|
|
1
|
-
|
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 './compoments/modal.js'
|
1
|
+
import { Modal, Input, Button } from './compoments/index.js'
|
38
2
|
import ReactDOM from 'react-dom/client'
|
39
|
-
import { useState } from'react'
|
3
|
+
import { useEffect, useState } from'react'
|
4
|
+
import Api from './resource.js'
|
40
5
|
|
41
6
|
export type ModalConfig = {
|
42
|
-
|
43
|
-
|
44
|
-
|
7
|
+
data: {
|
8
|
+
mobile: string;
|
9
|
+
verifyCodeKey: string;
|
10
|
+
sendSuccess: boolean;
|
11
|
+
};
|
45
12
|
onClose?: () => void
|
46
13
|
}
|
47
14
|
|
48
15
|
let modalRoot: ReactDOM.Root | null = null
|
49
16
|
|
50
|
-
|
51
|
-
const AntdModal = ({ config }: { config: ModalConfig }) => {
|
17
|
+
const ModalDom = ({ config }: { config: ModalConfig }) => {
|
52
18
|
const [visible, setVisible] = useState(true);
|
19
|
+
const [countdown, setCountdown] = useState(60);
|
20
|
+
const [captchaImage, setCaptchaImage] = useState<string>('');
|
21
|
+
const [captchCode, setCaptchCode] = useState<string>('');
|
22
|
+
const [captchaKey, setCaptchaKey] = useState<string>('');
|
23
|
+
const { data } = config || {};
|
24
|
+
const { mobile } = data || {};
|
25
|
+
|
26
|
+
|
27
|
+
const getKey = async () => {
|
28
|
+
const res = await Api.getCaptchaKey();
|
29
|
+
const { body: key } = res.data || {};
|
30
|
+
setCaptchaKey(key);
|
31
|
+
if(key) {
|
32
|
+
console.log('res=>key', key);
|
33
|
+
const image = Api.getCaptchaImgUrl(key) as unknown;
|
34
|
+
console.log('image', image);
|
35
|
+
setCaptchaImage(image as string);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
useEffect(() => {
|
40
|
+
let timer: number | null = null;
|
41
|
+
if (visible && countdown > 0) {
|
42
|
+
timer = setInterval(() => {
|
43
|
+
setCountdown((prev) => prev - 1);
|
44
|
+
}, 1000);
|
45
|
+
}
|
46
|
+
if (countdown === 0) {
|
47
|
+
getKey();
|
48
|
+
}
|
49
|
+
return () => {
|
50
|
+
if (timer) clearInterval(timer);
|
51
|
+
};
|
52
|
+
}, [visible, countdown]);
|
53
|
+
|
54
|
+
useEffect(() => {
|
55
|
+
console.log('mobile', mobile);
|
56
|
+
}, [])
|
57
|
+
|
58
|
+
const handleResend = async() => {
|
59
|
+
setCountdown(60);
|
60
|
+
const res = await Api.reSendCode({captchaKey, captcha: captchCode});
|
61
|
+
console.log('handleResend=>res', res);
|
62
|
+
// message.success('发送成功');
|
63
|
+
}
|
53
64
|
|
54
65
|
return (
|
55
66
|
<Modal
|
@@ -59,20 +70,39 @@ const AntdModal = ({ config }: { config: ModalConfig }) => {
|
|
59
70
|
config.onClose?.();
|
60
71
|
}}
|
61
72
|
>
|
62
|
-
{
|
73
|
+
<div>已发送短信至您的手机:{mobile}</div>
|
74
|
+
{countdown > 0 ? null : <div style={{ marginTop: 8, display: 'flex', alignItems: 'center', width: 300 }}>
|
75
|
+
<Input onChange={(e) => {
|
76
|
+
setCaptchCode(e as string)
|
77
|
+
}} />
|
78
|
+
|
79
|
+
{captchaImage && <img src={captchaImage} alt="验证码" style={{ width: 100, height: 30, marginLeft: 8 }} onClick={getKey} />}
|
80
|
+
</div>}
|
81
|
+
{countdown > 0 ? null : <div>请输入图形验证码后,重新发送验证码</div>}
|
82
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }}>
|
83
|
+
<Input
|
84
|
+
onChange={(val) => {console.log('change', val)}}
|
85
|
+
/>
|
86
|
+
<Button
|
87
|
+
disabled={countdown > 0 || !captchCode}
|
88
|
+
onClick={handleResend}
|
89
|
+
>
|
90
|
+
{countdown > 0 ? `${countdown}秒` : '重新发送'}
|
91
|
+
</Button>
|
92
|
+
</div>
|
63
93
|
</Modal>
|
64
94
|
);
|
65
95
|
};
|
66
96
|
// ... existing code ...
|
67
97
|
|
68
|
-
export const
|
98
|
+
export const createMessageVerifyModal = (config: ModalConfig) => {
|
69
99
|
const container = document.createElement('div')
|
70
100
|
container.id = 'antd-modal-container'
|
71
101
|
document.body.appendChild(container)
|
72
102
|
|
73
103
|
modalRoot = ReactDOM.createRoot(container)
|
74
104
|
modalRoot.render(
|
75
|
-
<
|
105
|
+
<ModalDom
|
76
106
|
config={{
|
77
107
|
...config,
|
78
108
|
onClose: () => {
|
package/src/main.tsx
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
import { createRoot } from 'react-dom/client';
|
2
|
-
import {
|
2
|
+
import { createMessageVerifyModal } from './index.js'; // 或 './index'
|
3
|
+
|
4
|
+
const data = {
|
5
|
+
mobile: '185****7760',
|
6
|
+
verifyCodeKey: 'e381c5f9-c7f4-4bf1-a948-744334fb0203',
|
7
|
+
sendSuccess: true
|
8
|
+
}
|
3
9
|
|
4
10
|
createRoot(document.getElementById('root')!).render(
|
5
|
-
<button onClick={() =>
|
11
|
+
<button onClick={() => createMessageVerifyModal({ data })}>
|
6
12
|
Show Modal
|
7
13
|
</button>);
|