message-verify 1.0.1-beta.0 → 1.0.1-beta.10
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 +2 -1
- package/dist/index.js +18 -3
- package/dist/locales/en.d.ts +3 -0
- package/dist/locales/en.js +4 -1
- package/dist/locales/id.d.ts +3 -0
- package/dist/locales/id.js +4 -1
- package/dist/locales/zh.d.ts +3 -0
- package/dist/locales/zh.js +4 -1
- package/dist/main.js +54 -8
- package/dist/relogin-modal.d.ts +2 -2
- package/dist/relogin-modal.js +8 -7
- package/dist/utils/type.d.ts +6 -1
- package/dist/verify-modal.js +14 -3
- package/package.json +1 -1
- package/src/index.tsx +26 -4
- package/src/locales/en.ts +4 -1
- package/src/locales/id.ts +4 -1
- package/src/locales/zh.ts +4 -1
- package/src/main.tsx +58 -9
- package/src/relogin-modal.tsx +11 -10
- package/src/utils/type.ts +7 -1
- package/src/verify-modal.tsx +13 -3
package/dist/index.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
-
import { ModalConfig } from './utils/type.js';
|
1
|
+
import { ModalConfig, LoginModalConfig } from './utils/type.js';
|
2
2
|
export declare const initFingerprint: () => Promise<string>;
|
3
3
|
export declare const createMessageVerifyModal: (modalProps: ModalConfig) => void;
|
4
|
+
export declare const createReLoginModal: (modalProps: LoginModalConfig) => void;
|
package/dist/index.js
CHANGED
@@ -2,16 +2,18 @@ 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
|
import Fingerprint2 from 'fingerprintjs2';
|
5
|
+
import ReLoginModal from './relogin-modal.js';
|
5
6
|
let cachedFingerprint = null;
|
6
7
|
export const initFingerprint = async () => {
|
8
|
+
// 优先从 window 取
|
9
|
+
if (typeof window !== 'undefined' && window.__YQG_FINGERPRINT__) {
|
10
|
+
return Promise.resolve(window.__YQG_FINGERPRINT__);
|
11
|
+
}
|
7
12
|
if (cachedFingerprint) {
|
8
|
-
// 已有缓存,直接返回 Promise
|
9
13
|
return Promise.resolve(cachedFingerprint);
|
10
14
|
}
|
11
|
-
// 首次异步获取并缓存
|
12
15
|
return new Promise((resolve) => {
|
13
16
|
Fingerprint2.get(function (components) {
|
14
|
-
console.log('components', components);
|
15
17
|
const includeKeys = ['userAgent', 'deviceMemory', 'cpuClass', 'hardwareConcurrency', 'platform'];
|
16
18
|
const values = components
|
17
19
|
.filter(component => includeKeys.includes(component.key))
|
@@ -19,6 +21,9 @@ export const initFingerprint = async () => {
|
|
19
21
|
.join('###');
|
20
22
|
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
21
23
|
cachedFingerprint = fingerprint;
|
24
|
+
if (typeof window !== 'undefined') {
|
25
|
+
window.__YQG_FINGERPRINT__ = fingerprint;
|
26
|
+
}
|
22
27
|
resolve(fingerprint);
|
23
28
|
});
|
24
29
|
});
|
@@ -37,6 +42,16 @@ export const createMessageVerifyModal = (modalProps) => {
|
|
37
42
|
}
|
38
43
|
} }));
|
39
44
|
};
|
45
|
+
// 新增 relogin 弹窗创建方法
|
46
|
+
export const createReLoginModal = (modalProps) => {
|
47
|
+
const container = document.createElement('div');
|
48
|
+
container.id = 'antd-modal-container';
|
49
|
+
document.body.appendChild(container);
|
50
|
+
modalRoot = ReactDOM.createRoot(container);
|
51
|
+
modalRoot.render(_jsx(ReLoginModal, { props: {
|
52
|
+
...modalProps,
|
53
|
+
} }));
|
54
|
+
};
|
40
55
|
const destroyModal = () => {
|
41
56
|
if (modalRoot) {
|
42
57
|
modalRoot.unmount();
|
package/dist/locales/en.d.ts
CHANGED
package/dist/locales/en.js
CHANGED
@@ -6,5 +6,8 @@ export default {
|
|
6
6
|
sendSuccess: 'Successfully sent',
|
7
7
|
sendFailed: 'Send failed',
|
8
8
|
reSend: 'Resend',
|
9
|
-
countDownSecound: '{countdown} seconds'
|
9
|
+
countDownSecound: '{countdown} seconds',
|
10
|
+
accountAlert: 'Account Security Alert',
|
11
|
+
alertContent: 'Changes have been detected in your login environment or network information.To ensure account security, please log in again to verify your identity.',
|
12
|
+
ok: 'OK'
|
10
13
|
};
|
package/dist/locales/id.d.ts
CHANGED
package/dist/locales/id.js
CHANGED
@@ -6,5 +6,8 @@ export default {
|
|
6
6
|
sendSuccess: 'Berhasil dikirim',
|
7
7
|
sendFailed: 'Gagal mengirim',
|
8
8
|
reSend: 'Kirim Ulang',
|
9
|
-
countDownSecound: '{countdown} detik'
|
9
|
+
countDownSecound: '{countdown} detik',
|
10
|
+
accountAlert: 'Peringatan Keamanan Akun',
|
11
|
+
alertContent: 'Terdeteksi perubahan pada lingkungan login atau informasi jaringan Anda.Untuk menjaga keamanan akun, silakan login kembali untuk memverifikasi identitas Anda.',
|
12
|
+
ok: 'Baiklah'
|
10
13
|
};
|
package/dist/locales/zh.d.ts
CHANGED
package/dist/locales/zh.js
CHANGED
package/dist/main.js
CHANGED
@@ -1,13 +1,59 @@
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import { createRoot } from 'react-dom/client';
|
3
|
-
import { createMessageVerifyModal, initFingerprint } from './index.js'; // 或 './index'
|
3
|
+
import { createMessageVerifyModal, initFingerprint, createReLoginModal } from './index.js'; // 或 './index'
|
4
4
|
import { axios } from '@yqg/resource';
|
5
5
|
const data = "{\"mobile\":\"188****4035\",\"verifyCodeKey\":\"3f025b33-988e-47c0-950d-6beb776d043f\",\"needValid\":true,\"step\":2,\"message\":\"需要填写验证码\"}";
|
6
6
|
const fp = await initFingerprint();
|
7
7
|
console.log(fp);
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
const config = {
|
9
|
+
"transitional": {
|
10
|
+
"silentJSONParsing": true,
|
11
|
+
"forcedJSONParsing": true,
|
12
|
+
"clarifyTimeoutError": false
|
13
|
+
},
|
14
|
+
"transformRequest": [
|
15
|
+
null
|
16
|
+
],
|
17
|
+
"transformResponse": [
|
18
|
+
null
|
19
|
+
],
|
20
|
+
"timeout": 0,
|
21
|
+
"xsrfCookieName": "XSRF-TOKEN",
|
22
|
+
"xsrfHeaderName": "X-XSRF-TOKEN",
|
23
|
+
"maxContentLength": -1,
|
24
|
+
"maxBodyLength": -1,
|
25
|
+
"headers": {
|
26
|
+
"Accept": "application/json, text/plain, */*",
|
27
|
+
"X-Device-Fingerprint": "185fcce88c629725321adf29daa5e444",
|
28
|
+
"Content-Type": "application/json",
|
29
|
+
"sms-code": "121212",
|
30
|
+
"sms-code-key": "212190c7-2f5e-4cc1-82ec-a242c2ab5425"
|
31
|
+
},
|
32
|
+
"url": "/classification/admin/level/edit",
|
33
|
+
"method": "post",
|
34
|
+
"dataFormat": "JSON",
|
35
|
+
"showRequestData": true,
|
36
|
+
"showResponseData": false,
|
37
|
+
"showGeneralResponseData": true,
|
38
|
+
"headersList": [],
|
39
|
+
"requestDataFunc": "\nfunction(formFilterData){\n // 这里写你的处理逻辑\n return {\n ...formFilterData,\n 'classificationLevel': 2 //等级\n }\n}\n",
|
40
|
+
"responseDataFunc": "",
|
41
|
+
"responseGeneralDataFunc": "function(req, { data, util, window }) {\n return req\n .then((response) => {\n return Promise.resolve({\n status: {\n code: 0,\n }\n })\n })\n .catch((error) => {\n // 检查是否有响应数据\n if (error.response && error.response.data) {\n const responseData = error.response.data;\n const detail = responseData.body?.status?.detail || responseData.status?.detail;\n if (detail) {\n util.message.error(detail);\n } else {\n util.message.error('编辑失败,请重试');\n }\n } else {\n util.message.error('编辑失败,请重试');\n }\n console.error('Error during deletion:', error);\n });\n}",
|
42
|
+
"formInstance": {},
|
43
|
+
"data": "{\"id\":1,\"classificationName\":\"个人基本概况信息\",\"classificationLevel\":2}",
|
44
|
+
"baseURL": "http://localhost:62888"
|
45
|
+
};
|
46
|
+
createRoot(document.getElementById('root')).render(_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => createMessageVerifyModal({
|
47
|
+
data,
|
48
|
+
config,
|
49
|
+
response: {
|
50
|
+
config
|
51
|
+
},
|
52
|
+
lang: 'en',
|
53
|
+
http: axios,
|
54
|
+
}), children: "Show verify Modal" }), _jsx("button", { onClick: () => createReLoginModal({
|
55
|
+
goLogin: () => {
|
56
|
+
console.log('goLogin');
|
57
|
+
},
|
58
|
+
lang: 'zh',
|
59
|
+
}), children: "Show login Modal" })] }));
|
package/dist/relogin-modal.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { LoginModalConfig } from './utils/type.js';
|
2
2
|
declare const ReLoginModal: ({ props }: {
|
3
|
-
props:
|
3
|
+
props: LoginModalConfig;
|
4
4
|
}) => import("react/jsx-runtime.js").JSX.Element;
|
5
5
|
export default ReLoginModal;
|
package/dist/relogin-modal.js
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import { useState } from 'react';
|
3
3
|
import { Modal, Button } from './compoments/index.js';
|
4
|
+
import t from './utils/i18n.js';
|
4
5
|
const ReLoginModal = ({ props }) => {
|
5
|
-
|
6
|
+
const { goLogin, lang } = props || {};
|
6
7
|
const [visible, setVisible] = useState(true);
|
7
8
|
const onClose = () => {
|
8
9
|
setVisible(false);
|
10
|
+
goLogin();
|
9
11
|
};
|
10
|
-
return (_jsxs(Modal, { visible: visible, onClose: onClose, width: 420, children: [_jsx("div", { style: { fontWeight: 500, fontSize: 20, marginBottom: 24 }, children:
|
12
|
+
return (_jsxs(Modal, { visible: visible, onClose: onClose, width: 420, children: [_jsx("div", { style: { fontWeight: 500, fontSize: 20, marginBottom: 24 }, children: t('accountAlert', lang) }), _jsx("div", { style: { color: '#222', fontSize: 16, marginBottom: 40, lineHeight: '24px' }, children: t('alertContent', lang) }), _jsx("div", { style: { display: 'flex', justifyContent: 'center' }, children: _jsx(Button, { style: {
|
11
13
|
background: '#1677ff',
|
12
14
|
color: '#fff',
|
13
15
|
border: 'none',
|
14
|
-
width:
|
15
|
-
height:
|
16
|
-
fontSize:
|
17
|
-
fontWeight: 500,
|
16
|
+
width: 80,
|
17
|
+
height: 36,
|
18
|
+
fontSize: 14,
|
18
19
|
borderRadius: 8,
|
19
20
|
boxShadow: '0 2px 8px rgba(22,119,255,0.08)',
|
20
|
-
}, onClick: onClose, children:
|
21
|
+
}, onClick: onClose, children: t('ok', lang) }) })] }));
|
21
22
|
};
|
22
23
|
export default ReLoginModal;
|
package/dist/utils/type.d.ts
CHANGED
@@ -7,7 +7,7 @@ export type ModalConfig = {
|
|
7
7
|
};
|
8
8
|
[key: string]: unknown;
|
9
9
|
};
|
10
|
-
lang
|
10
|
+
lang?: 'zh' | 'en' | 'id';
|
11
11
|
http: {
|
12
12
|
(params: object): Promise<unknown>;
|
13
13
|
defaults: {
|
@@ -19,4 +19,9 @@ export type ModalConfig = {
|
|
19
19
|
};
|
20
20
|
};
|
21
21
|
api?: string;
|
22
|
+
response: any;
|
23
|
+
};
|
24
|
+
export type LoginModalConfig = {
|
25
|
+
goLogin: () => void;
|
26
|
+
lang?: 'zh' | 'en' | 'id';
|
22
27
|
};
|
package/dist/verify-modal.js
CHANGED
@@ -11,7 +11,7 @@ const CreateMessageVerifyModal = ({ props }) => {
|
|
11
11
|
const [captchaImage, setCaptchaImage] = useState('');
|
12
12
|
const [captchCode, setCaptchCode] = useState('');
|
13
13
|
const [captchaKey, setCaptchaKey] = useState('');
|
14
|
-
const { data,
|
14
|
+
const { data, http, lang, api = '/admin/sms/send', response } = props || {};
|
15
15
|
const dataObj = JSON.parse(data || '{}');
|
16
16
|
const { mobile, verifyCodeKey } = dataObj || {};
|
17
17
|
const getKey = async () => {
|
@@ -66,15 +66,26 @@ const CreateMessageVerifyModal = ({ props }) => {
|
|
66
66
|
}, 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) => {
|
67
67
|
setOtp(val);
|
68
68
|
if (val.length === 6) {
|
69
|
+
const { data: { status: { code, detail } = {} } } = response || {};
|
69
70
|
http({
|
70
|
-
...config,
|
71
|
+
...response?.config,
|
71
72
|
headers: {
|
72
73
|
...http.defaults.headers.common,
|
73
74
|
'sms-code': val,
|
74
75
|
'sms-code-key': verifyCodeKey,
|
75
|
-
'Content-Type': config.headers['Content-Type'],
|
76
|
+
'Content-Type': response?.config.headers['Content-Type'],
|
76
77
|
}
|
77
78
|
});
|
79
|
+
console.log('=>response===>', response);
|
80
|
+
if (code !== 0) {
|
81
|
+
const detailObj = JSON.parse(detail || '{}');
|
82
|
+
message.error(detailObj?.message || t('verifyFailed', lang));
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
else {
|
86
|
+
message.success(t('verifySuccess', lang));
|
87
|
+
// setVisible(false);
|
88
|
+
}
|
78
89
|
setVisible(false);
|
79
90
|
}
|
80
91
|
} }), _jsx(Button, { disabled: countdown > 0 || !captchCode, onClick: handleResend, style: { padding: '8px' }, children: countdown > 0 ? t('countDownSecound', lang, { countdown }) : t('reSend', lang) })] }), countdown > 0 ? null :
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
@@ -1,18 +1,21 @@
|
|
1
1
|
import ReactDOM from 'react-dom/client'
|
2
2
|
import VerifyModal from './verify-modal.js'
|
3
3
|
import Fingerprint2 from 'fingerprintjs2';
|
4
|
-
import
|
4
|
+
import ReLoginModal from './relogin-modal.js';
|
5
|
+
import { ModalConfig, LoginModalConfig } from './utils/type.js';
|
5
6
|
|
6
7
|
let cachedFingerprint: string | null = null;
|
8
|
+
|
7
9
|
export const initFingerprint = async (): Promise<string> => {
|
10
|
+
// 优先从 window 取
|
11
|
+
if (typeof window !== 'undefined' && (window as any).__YQG_FINGERPRINT__) {
|
12
|
+
return Promise.resolve((window as any).__YQG_FINGERPRINT__);
|
13
|
+
}
|
8
14
|
if (cachedFingerprint) {
|
9
|
-
// 已有缓存,直接返回 Promise
|
10
15
|
return Promise.resolve(cachedFingerprint);
|
11
16
|
}
|
12
|
-
// 首次异步获取并缓存
|
13
17
|
return new Promise((resolve) => {
|
14
18
|
Fingerprint2.get(function (components) {
|
15
|
-
console.log('components', components);
|
16
19
|
const includeKeys = ['userAgent', 'deviceMemory', 'cpuClass', 'hardwareConcurrency', 'platform'];
|
17
20
|
const values = components
|
18
21
|
.filter(component => includeKeys.includes(component.key))
|
@@ -20,6 +23,9 @@ export const initFingerprint = async (): Promise<string> => {
|
|
20
23
|
.join('###');
|
21
24
|
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
22
25
|
cachedFingerprint = fingerprint;
|
26
|
+
if (typeof window !== 'undefined') {
|
27
|
+
(window as any).__YQG_FINGERPRINT__ = fingerprint;
|
28
|
+
}
|
23
29
|
resolve(fingerprint);
|
24
30
|
});
|
25
31
|
});
|
@@ -46,6 +52,22 @@ export const createMessageVerifyModal = (modalProps: ModalConfig) => {
|
|
46
52
|
)
|
47
53
|
}
|
48
54
|
|
55
|
+
// 新增 relogin 弹窗创建方法
|
56
|
+
export const createReLoginModal = (modalProps: LoginModalConfig) => {
|
57
|
+
const container = document.createElement('div')
|
58
|
+
container.id = 'antd-modal-container'
|
59
|
+
document.body.appendChild(container)
|
60
|
+
|
61
|
+
modalRoot = ReactDOM.createRoot(container)
|
62
|
+
modalRoot.render(
|
63
|
+
<ReLoginModal
|
64
|
+
props={{
|
65
|
+
...modalProps,
|
66
|
+
}}
|
67
|
+
/>
|
68
|
+
)
|
69
|
+
}
|
70
|
+
|
49
71
|
const destroyModal = () => {
|
50
72
|
if (modalRoot) {
|
51
73
|
modalRoot.unmount()
|
package/src/locales/en.ts
CHANGED
@@ -6,5 +6,8 @@ export default {
|
|
6
6
|
sendSuccess: 'Successfully sent',
|
7
7
|
sendFailed: 'Send failed',
|
8
8
|
reSend: 'Resend',
|
9
|
-
countDownSecound: '{countdown} seconds'
|
9
|
+
countDownSecound: '{countdown} seconds',
|
10
|
+
accountAlert: 'Account Security Alert',
|
11
|
+
alertContent: 'Changes have been detected in your login environment or network information.To ensure account security, please log in again to verify your identity.',
|
12
|
+
ok: 'OK'
|
10
13
|
};
|
package/src/locales/id.ts
CHANGED
@@ -6,5 +6,8 @@ export default {
|
|
6
6
|
sendSuccess: 'Berhasil dikirim',
|
7
7
|
sendFailed: 'Gagal mengirim',
|
8
8
|
reSend: 'Kirim Ulang',
|
9
|
-
countDownSecound: '{countdown} detik'
|
9
|
+
countDownSecound: '{countdown} detik',
|
10
|
+
accountAlert: 'Peringatan Keamanan Akun',
|
11
|
+
alertContent: 'Terdeteksi perubahan pada lingkungan login atau informasi jaringan Anda.Untuk menjaga keamanan akun, silakan login kembali untuk memverifikasi identitas Anda.',
|
12
|
+
ok: 'Baiklah'
|
10
13
|
};
|
package/src/locales/zh.ts
CHANGED
package/src/main.tsx
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { createRoot } from 'react-dom/client';
|
2
|
-
import { createMessageVerifyModal, initFingerprint } from './index.js'; // 或 './index'
|
2
|
+
import { createMessageVerifyModal, initFingerprint, createReLoginModal } from './index.js'; // 或 './index'
|
3
3
|
import { axios } from '@yqg/resource';
|
4
4
|
|
5
5
|
const data = "{\"mobile\":\"188****4035\",\"verifyCodeKey\":\"3f025b33-988e-47c0-950d-6beb776d043f\",\"needValid\":true,\"step\":2,\"message\":\"需要填写验证码\"}";
|
@@ -7,14 +7,63 @@ const data = "{\"mobile\":\"188****4035\",\"verifyCodeKey\":\"3f025b33-988e-47c0
|
|
7
7
|
const fp = await initFingerprint();
|
8
8
|
console.log(fp);
|
9
9
|
|
10
|
+
const config = {
|
11
|
+
"transitional": {
|
12
|
+
"silentJSONParsing": true,
|
13
|
+
"forcedJSONParsing": true,
|
14
|
+
"clarifyTimeoutError": false
|
15
|
+
},
|
16
|
+
"transformRequest": [
|
17
|
+
null
|
18
|
+
],
|
19
|
+
"transformResponse": [
|
20
|
+
null
|
21
|
+
],
|
22
|
+
"timeout": 0,
|
23
|
+
"xsrfCookieName": "XSRF-TOKEN",
|
24
|
+
"xsrfHeaderName": "X-XSRF-TOKEN",
|
25
|
+
"maxContentLength": -1,
|
26
|
+
"maxBodyLength": -1,
|
27
|
+
"headers": {
|
28
|
+
"Accept": "application/json, text/plain, */*",
|
29
|
+
"X-Device-Fingerprint": "185fcce88c629725321adf29daa5e444",
|
30
|
+
"Content-Type": "application/json",
|
31
|
+
"sms-code": "121212",
|
32
|
+
"sms-code-key": "212190c7-2f5e-4cc1-82ec-a242c2ab5425"
|
33
|
+
},
|
34
|
+
"url": "/classification/admin/level/edit",
|
35
|
+
"method": "post",
|
36
|
+
"dataFormat": "JSON",
|
37
|
+
"showRequestData": true,
|
38
|
+
"showResponseData": false,
|
39
|
+
"showGeneralResponseData": true,
|
40
|
+
"headersList": [],
|
41
|
+
"requestDataFunc": "\nfunction(formFilterData){\n // 这里写你的处理逻辑\n return {\n ...formFilterData,\n 'classificationLevel': 2 //等级\n }\n}\n",
|
42
|
+
"responseDataFunc": "",
|
43
|
+
"responseGeneralDataFunc": "function(req, { data, util, window }) {\n return req\n .then((response) => {\n return Promise.resolve({\n status: {\n code: 0,\n }\n })\n })\n .catch((error) => {\n // 检查是否有响应数据\n if (error.response && error.response.data) {\n const responseData = error.response.data;\n const detail = responseData.body?.status?.detail || responseData.status?.detail;\n if (detail) {\n util.message.error(detail);\n } else {\n util.message.error('编辑失败,请重试');\n }\n } else {\n util.message.error('编辑失败,请重试');\n }\n console.error('Error during deletion:', error);\n });\n}",
|
44
|
+
"formInstance": {},
|
45
|
+
"data": "{\"id\":1,\"classificationName\":\"个人基本概况信息\",\"classificationLevel\":2}",
|
46
|
+
"baseURL": "http://localhost:62888"
|
47
|
+
};
|
10
48
|
createRoot(document.getElementById('root')!).render(
|
11
49
|
<>
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
50
|
+
<button onClick={() => createMessageVerifyModal({
|
51
|
+
data,
|
52
|
+
config,
|
53
|
+
response: {
|
54
|
+
config
|
55
|
+
},
|
56
|
+
lang: 'en',
|
57
|
+
http: axios,
|
58
|
+
})}>
|
59
|
+
Show verify Modal
|
60
|
+
</button>
|
61
|
+
<button onClick={() => createReLoginModal({
|
62
|
+
goLogin: () => {
|
63
|
+
console.log('goLogin');
|
64
|
+
},
|
65
|
+
lang: 'zh',
|
66
|
+
})}>
|
67
|
+
Show login Modal
|
68
|
+
</button>
|
20
69
|
</>);
|
package/src/relogin-modal.tsx
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
import { useState } from 'react'
|
2
2
|
import { Modal, Button } from './compoments/index.js'
|
3
|
-
import {
|
3
|
+
import { LoginModalConfig } from './utils/type.js';
|
4
|
+
import t from './utils/i18n.js'
|
4
5
|
|
5
|
-
const ReLoginModal = ({ props }: { props:
|
6
|
-
|
6
|
+
const ReLoginModal = ({ props }: { props: LoginModalConfig }) => {
|
7
|
+
const { goLogin, lang } = props || {};
|
7
8
|
const [visible, setVisible] = useState(true);
|
8
9
|
const onClose = () => {
|
9
10
|
setVisible(false);
|
11
|
+
goLogin();
|
10
12
|
};
|
11
13
|
return (
|
12
14
|
<Modal visible={visible} onClose={onClose} width={420}>
|
13
15
|
<div style={{ fontWeight: 500, fontSize: 20, marginBottom: 24 }}>
|
14
|
-
|
16
|
+
{t('accountAlert', lang)}
|
15
17
|
</div>
|
16
18
|
<div style={{ color: '#222', fontSize: 16, marginBottom: 40, lineHeight: '24px' }}>
|
17
|
-
|
19
|
+
{t('alertContent', lang)}
|
18
20
|
</div>
|
19
21
|
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
20
22
|
<Button
|
@@ -22,16 +24,15 @@ const ReLoginModal = ({ props }: { props: ModalConfig }) => {
|
|
22
24
|
background: '#1677ff',
|
23
25
|
color: '#fff',
|
24
26
|
border: 'none',
|
25
|
-
width:
|
26
|
-
height:
|
27
|
-
fontSize:
|
28
|
-
fontWeight: 500,
|
27
|
+
width: 80,
|
28
|
+
height: 36,
|
29
|
+
fontSize: 14,
|
29
30
|
borderRadius: 8,
|
30
31
|
boxShadow: '0 2px 8px rgba(22,119,255,0.08)',
|
31
32
|
}}
|
32
33
|
onClick={onClose}
|
33
34
|
>
|
34
|
-
|
35
|
+
{t('ok', lang)}
|
35
36
|
</Button>
|
36
37
|
</div>
|
37
38
|
</Modal>
|
package/src/utils/type.ts
CHANGED
@@ -8,7 +8,7 @@ export type ModalConfig = {
|
|
8
8
|
};
|
9
9
|
[key: string]: unknown;
|
10
10
|
};
|
11
|
-
lang
|
11
|
+
lang?: 'zh' | 'en' | 'id';
|
12
12
|
http: {
|
13
13
|
(params: object): Promise<unknown>;
|
14
14
|
defaults: {
|
@@ -20,4 +20,10 @@ export type ModalConfig = {
|
|
20
20
|
}
|
21
21
|
};
|
22
22
|
api?: string;
|
23
|
+
response: any;
|
24
|
+
}
|
25
|
+
|
26
|
+
export type LoginModalConfig = {
|
27
|
+
goLogin: () => void;
|
28
|
+
lang?: 'zh' | 'en' | 'id';
|
23
29
|
}
|
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,
|
15
|
+
const { data, http, lang, api='/admin/sms/send', response } = props || {};
|
16
16
|
const dataObj = JSON.parse(data || '{}');
|
17
17
|
const { mobile, verifyCodeKey } = dataObj || {};
|
18
18
|
|
@@ -81,15 +81,25 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
81
81
|
onChange={async (val) => {
|
82
82
|
setOtp(val);
|
83
83
|
if (val.length === 6) {
|
84
|
+
const {data: {status: {code, detail} = {}}} = response || {};
|
84
85
|
http({
|
85
|
-
...config,
|
86
|
+
...response?.config,
|
86
87
|
headers: {
|
87
88
|
...http.defaults.headers.common,
|
88
89
|
'sms-code': val,
|
89
90
|
'sms-code-key': verifyCodeKey,
|
90
|
-
'Content-Type': config.headers['Content-Type'],
|
91
|
+
'Content-Type': response?.config.headers['Content-Type'],
|
91
92
|
}
|
92
93
|
}) as any;
|
94
|
+
console.log('=>response===>', response);
|
95
|
+
if(code !== 0) {
|
96
|
+
const detailObj = JSON.parse(detail || '{}');
|
97
|
+
message.error(detailObj?.message || t('verifyFailed', lang));
|
98
|
+
return;
|
99
|
+
} else {
|
100
|
+
message.success(t('verifySuccess', lang));
|
101
|
+
// setVisible(false);
|
102
|
+
}
|
93
103
|
setVisible(false);
|
94
104
|
}
|
95
105
|
}} />
|