message-verify 1.0.1-beta.19 → 1.0.1-beta.20
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/verify-modal.js +22 -16
- package/package.json +1 -1
- package/src/verify-modal.tsx +27 -21
package/dist/verify-modal.js
CHANGED
@@ -65,27 +65,33 @@ const CreateMessageVerifyModal = ({ props }) => {
|
|
65
65
|
return (_jsxs(Modal, { width: 420, visible: visible, onClose: () => {
|
66
66
|
setVisible(false);
|
67
67
|
props.onClose?.();
|
68
|
-
}, children: [_jsx("div", { style: { fontSize: 14, color: '#666' }, children: t('alreadySend', lang, { phone: mobile }) }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 12 }, children: [_jsx(Input.OTP, { length: 6, value: otp, onChange: (val) => {
|
68
|
+
}, children: [_jsx("div", { style: { fontSize: 14, color: '#666' }, children: t('alreadySend', lang, { phone: mobile }) }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 12 }, children: [_jsx(Input.OTP, { length: 6, value: otp, onChange: async (val) => {
|
69
69
|
setOtp(val);
|
70
70
|
if (val.length === 6) {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
try {
|
72
|
+
const res = await http({
|
73
|
+
...config,
|
74
|
+
headers: {
|
75
|
+
...http.defaults.headers.common,
|
76
|
+
'sms-code': val,
|
77
|
+
'sms-code-key': verifyCodeKey,
|
78
|
+
'Content-Type': config.headers['Content-Type'],
|
79
|
+
}
|
80
|
+
});
|
81
|
+
if (!res) {
|
82
|
+
message.error('验证失败');
|
83
|
+
apiReject();
|
78
84
|
}
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
85
|
+
else {
|
86
|
+
apiResolve(res);
|
87
|
+
}
|
88
|
+
setVisible(false);
|
89
|
+
}
|
90
|
+
catch (error) {
|
83
91
|
message.error('验证失败');
|
84
|
-
apiReject(
|
85
|
-
}).finally(() => {
|
86
|
-
console.log('finally');
|
92
|
+
apiReject(error);
|
87
93
|
setVisible(false);
|
88
|
-
}
|
94
|
+
}
|
89
95
|
}
|
90
96
|
} }), _jsx(Button, { disabled: countdown > 0 || !captchCode, onClick: handleResend, style: { padding: '8px' }, children: countdown > 0 ? t('countDownSecound', lang, { countdown }) : t('reSend', lang) })] }), countdown > 0 ? null :
|
91
97
|
_jsxs("div", { style: { marginTop: 12, display: 'flex', alignItems: 'center' }, children: [_jsx(Input, { placeholder: t('pleaseEnterPicVerifyCode', lang), onChange: (e) => {
|
package/package.json
CHANGED
package/src/verify-modal.tsx
CHANGED
@@ -12,7 +12,7 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
12
12
|
const [captchaImage, setCaptchaImage] = useState<string>('');
|
13
13
|
const [captchCode, setCaptchCode] = useState<string>('');
|
14
14
|
const [captchaKey, setCaptchaKey] = useState<string>('');
|
15
|
-
const { data, http, lang, api='/admin/sms/send', config, apiResolve, apiReject } = props || {};
|
15
|
+
const { data, http, lang, api = '/admin/sms/send', config, apiResolve, apiReject } = props || {};
|
16
16
|
const dataObj = JSON.parse(data || '{}');
|
17
17
|
const { mobile, verifyCodeKey } = dataObj || {};
|
18
18
|
|
@@ -25,10 +25,11 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
25
25
|
const image = Api.getCaptchaImgUrl(key) as unknown;
|
26
26
|
setCaptchaImage(image as string);
|
27
27
|
}
|
28
|
-
} catch (err) {
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
} catch (err) {
|
29
|
+
const msg =
|
30
|
+
typeof err === 'object' && err !== null && 'message' in err
|
31
|
+
? (err as { message: string }).message
|
32
|
+
: String(err);
|
32
33
|
message.error(msg as React.ReactNode);
|
33
34
|
}
|
34
35
|
}
|
@@ -80,27 +81,32 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
80
81
|
<Input.OTP
|
81
82
|
length={6}
|
82
83
|
value={otp}
|
83
|
-
onChange={(val) => {
|
84
|
+
onChange={async (val) => {
|
84
85
|
setOtp(val);
|
85
86
|
if (val.length === 6) {
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
...
|
90
|
-
|
91
|
-
|
92
|
-
|
87
|
+
try {
|
88
|
+
|
89
|
+
const res = await http({
|
90
|
+
...config,
|
91
|
+
headers: {
|
92
|
+
...http.defaults.headers.common,
|
93
|
+
'sms-code': val,
|
94
|
+
'sms-code-key': verifyCodeKey,
|
95
|
+
'Content-Type': config.headers['Content-Type'],
|
96
|
+
}
|
97
|
+
})
|
98
|
+
if (!res) {
|
99
|
+
message.error('验证失败');
|
100
|
+
apiReject();
|
101
|
+
} else {
|
102
|
+
apiResolve(res);
|
93
103
|
}
|
94
|
-
|
95
|
-
|
96
|
-
apiResolve(res);
|
97
|
-
}).catch(err => {
|
104
|
+
setVisible(false);
|
105
|
+
} catch (error) {
|
98
106
|
message.error('验证失败');
|
99
|
-
apiReject(
|
100
|
-
}).finally(() => {
|
101
|
-
console.log('finally');
|
107
|
+
apiReject(error);
|
102
108
|
setVisible(false);
|
103
|
-
}
|
109
|
+
}
|
104
110
|
}
|
105
111
|
}} />
|
106
112
|
<Button
|