message-verify 1.0.1-beta.19 → 1.0.1-beta.2
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 +1 -2
- package/dist/index.js +3 -19
- package/dist/locales/en.d.ts +0 -3
- package/dist/locales/en.js +1 -4
- package/dist/locales/id.d.ts +0 -3
- package/dist/locales/id.js +1 -4
- package/dist/locales/zh.d.ts +0 -3
- package/dist/locales/zh.js +1 -4
- package/dist/main.js +43 -45
- package/dist/relogin-modal.d.ts +2 -2
- package/dist/relogin-modal.js +7 -8
- package/dist/utils/type.d.ts +1 -7
- package/dist/verify-modal.js +11 -13
- package/package.json +2 -3
- package/src/index.tsx +4 -26
- package/src/locales/en.ts +1 -4
- package/src/locales/id.ts +1 -4
- package/src/locales/zh.ts +1 -4
- package/src/main.tsx +46 -51
- package/src/relogin-modal.tsx +10 -11
- package/src/utils/type.ts +1 -8
- package/src/verify-modal.tsx +12 -14
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { ModalConfig
|
1
|
+
import { ModalConfig } 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,19 +2,16 @@ 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';
|
6
5
|
let cachedFingerprint = null;
|
7
6
|
export const initFingerprint = async () => {
|
8
|
-
if (typeof window !== 'undefined') {
|
9
|
-
const local = localStorage.getItem('__YQG_FINGERPRINT__');
|
10
|
-
if (local)
|
11
|
-
return Promise.resolve(local);
|
12
|
-
}
|
13
7
|
if (cachedFingerprint) {
|
8
|
+
// 已有缓存,直接返回 Promise
|
14
9
|
return Promise.resolve(cachedFingerprint);
|
15
10
|
}
|
11
|
+
// 首次异步获取并缓存
|
16
12
|
return new Promise((resolve) => {
|
17
13
|
Fingerprint2.get(function (components) {
|
14
|
+
console.log('components', components);
|
18
15
|
const includeKeys = ['userAgent', 'deviceMemory', 'cpuClass', 'hardwareConcurrency', 'platform'];
|
19
16
|
const values = components
|
20
17
|
.filter(component => includeKeys.includes(component.key))
|
@@ -22,9 +19,6 @@ export const initFingerprint = async () => {
|
|
22
19
|
.join('###');
|
23
20
|
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
24
21
|
cachedFingerprint = fingerprint;
|
25
|
-
if (typeof window !== 'undefined') {
|
26
|
-
localStorage.setItem('__YQG_FINGERPRINT__', fingerprint);
|
27
|
-
}
|
28
22
|
resolve(fingerprint);
|
29
23
|
});
|
30
24
|
});
|
@@ -43,16 +37,6 @@ export const createMessageVerifyModal = (modalProps) => {
|
|
43
37
|
}
|
44
38
|
} }));
|
45
39
|
};
|
46
|
-
// 新增 relogin 弹窗创建方法
|
47
|
-
export const createReLoginModal = (modalProps) => {
|
48
|
-
const container = document.createElement('div');
|
49
|
-
container.id = 'antd-modal-container';
|
50
|
-
document.body.appendChild(container);
|
51
|
-
modalRoot = ReactDOM.createRoot(container);
|
52
|
-
modalRoot.render(_jsx(ReLoginModal, { props: {
|
53
|
-
...modalProps,
|
54
|
-
} }));
|
55
|
-
};
|
56
40
|
const destroyModal = () => {
|
57
41
|
if (modalRoot) {
|
58
42
|
modalRoot.unmount();
|
package/dist/locales/en.d.ts
CHANGED
package/dist/locales/en.js
CHANGED
@@ -6,8 +6,5 @@ export default {
|
|
6
6
|
sendSuccess: 'Successfully sent',
|
7
7
|
sendFailed: 'Send failed',
|
8
8
|
reSend: 'Resend',
|
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'
|
9
|
+
countDownSecound: '{countdown} seconds'
|
13
10
|
};
|
package/dist/locales/id.d.ts
CHANGED
package/dist/locales/id.js
CHANGED
@@ -6,8 +6,5 @@ export default {
|
|
6
6
|
sendSuccess: 'Berhasil dikirim',
|
7
7
|
sendFailed: 'Gagal mengirim',
|
8
8
|
reSend: 'Kirim Ulang',
|
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'
|
9
|
+
countDownSecound: '{countdown} detik'
|
13
10
|
};
|
package/dist/locales/zh.d.ts
CHANGED
package/dist/locales/zh.js
CHANGED
package/dist/main.js
CHANGED
@@ -1,52 +1,50 @@
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
2
2
|
import { createRoot } from 'react-dom/client';
|
3
|
-
import { createMessageVerifyModal, initFingerprint
|
3
|
+
import { createMessageVerifyModal, initFingerprint } 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
|
-
|
14
|
-
|
15
|
-
"xsrfCookieName": "XSRF-TOKEN",
|
16
|
-
"xsrfHeaderName": "X-XSRF-TOKEN",
|
17
|
-
"maxContentLength": -1,
|
18
|
-
"maxBodyLength": -1,
|
19
|
-
"headers": {
|
20
|
-
"Accept": "application/json, text/plain, */*",
|
21
|
-
"X-Device-Fingerprint": "185fcce88c629725321adf29daa5e444",
|
22
|
-
"Content-Type": "application/json"
|
23
|
-
},
|
24
|
-
"url": "/classification/admin/level/edit",
|
25
|
-
"method": "post",
|
26
|
-
"dataFormat": "JSON",
|
27
|
-
"showRequestData": true,
|
28
|
-
"showResponseData": false,
|
29
|
-
"showGeneralResponseData": true,
|
30
|
-
"headersList": [],
|
31
|
-
"requestDataFunc": "\nfunction(formFilterData){\n // 这里写你的处理逻辑\n return {\n ...formFilterData,\n 'classificationLevel': 2 //等级\n }\n}\n",
|
32
|
-
"responseDataFunc": "",
|
33
|
-
"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}",
|
34
|
-
"formInstance": {},
|
35
|
-
"data": "{\"id\":1,\"classificationName\":\"个人基本概况信息\",\"classificationLevel\":2}",
|
36
|
-
"baseURL": "http://localhost:62888"
|
37
|
-
};
|
38
|
-
createRoot(document.getElementById('root')).render(_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => createMessageVerifyModal({
|
39
|
-
data,
|
40
|
-
config,
|
41
|
-
lang: 'en',
|
42
|
-
http: axios,
|
43
|
-
apiReject: () => {
|
8
|
+
createRoot(document.getElementById('root')).render(_jsx(_Fragment, { children: _jsx("button", { onClick: () => createMessageVerifyModal({
|
9
|
+
data,
|
10
|
+
config: {
|
11
|
+
"transitional": {
|
12
|
+
"silentJSONParsing": true,
|
13
|
+
"forcedJSONParsing": true,
|
14
|
+
"clarifyTimeoutError": false
|
44
15
|
},
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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"
|
50
33
|
},
|
51
|
-
|
52
|
-
|
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
|
+
},
|
48
|
+
lang: 'en',
|
49
|
+
http: axios,
|
50
|
+
}), children: "Show verify Modal" }) }));
|
package/dist/relogin-modal.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { ModalConfig } from './utils/type.js';
|
2
2
|
declare const ReLoginModal: ({ props }: {
|
3
|
-
props:
|
3
|
+
props: ModalConfig;
|
4
4
|
}) => import("react/jsx-runtime.js").JSX.Element;
|
5
5
|
export default ReLoginModal;
|
package/dist/relogin-modal.js
CHANGED
@@ -1,23 +1,22 @@
|
|
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';
|
5
4
|
const ReLoginModal = ({ props }) => {
|
6
|
-
|
5
|
+
console.log('props', props);
|
7
6
|
const [visible, setVisible] = useState(true);
|
8
7
|
const onClose = () => {
|
9
8
|
setVisible(false);
|
10
|
-
goLogin();
|
11
9
|
};
|
12
|
-
return (_jsxs(Modal, { visible: visible, onClose: onClose, width: 420, children: [_jsx("div", { style: { fontWeight: 500, fontSize: 20, marginBottom: 24 }, children:
|
10
|
+
return (_jsxs(Modal, { visible: visible, onClose: onClose, width: 420, children: [_jsx("div", { style: { fontWeight: 500, fontSize: 20, marginBottom: 24 }, children: "\u8D26\u53F7\u5B89\u5168\u63D0\u9192" }), _jsx("div", { style: { color: '#222', fontSize: 16, marginBottom: 40, lineHeight: '24px' }, children: "\u68C0\u6D4B\u5230\u60A8\u7684\u767B\u5F55\u73AF\u5883\u6216\u7F51\u7EDC\u4FE1\u606F\u6709\u53D8\u52A8\uFF0C\u4E3A\u4FDD\u969C\u8D26\u6237\u5B89\u5168\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u9A8C\u8BC1\u8EAB\u4EFD" }), _jsx("div", { style: { display: 'flex', justifyContent: 'center' }, children: _jsx(Button, { style: {
|
13
11
|
background: '#1677ff',
|
14
12
|
color: '#fff',
|
15
13
|
border: 'none',
|
16
|
-
width:
|
17
|
-
height:
|
18
|
-
fontSize:
|
14
|
+
width: 160,
|
15
|
+
height: 44,
|
16
|
+
fontSize: 18,
|
17
|
+
fontWeight: 500,
|
19
18
|
borderRadius: 8,
|
20
19
|
boxShadow: '0 2px 8px rgba(22,119,255,0.08)',
|
21
|
-
}, onClick: onClose, children:
|
20
|
+
}, onClick: onClose, children: "\u597D\u7684" }) })] }));
|
22
21
|
};
|
23
22
|
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,10 +19,4 @@ export type ModalConfig = {
|
|
19
19
|
};
|
20
20
|
};
|
21
21
|
api?: string;
|
22
|
-
apiReject: any;
|
23
|
-
apiResolve: any;
|
24
|
-
};
|
25
|
-
export type LoginModalConfig = {
|
26
|
-
goLogin: () => void;
|
27
|
-
lang?: 'zh' | 'en' | 'id';
|
28
22
|
};
|
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, http, lang, api = '/admin/sms/send'
|
14
|
+
const { data, config, http, lang, api = '/admin/sms/send' } = props || {};
|
15
15
|
const dataObj = JSON.parse(data || '{}');
|
16
16
|
const { mobile, verifyCodeKey } = dataObj || {};
|
17
17
|
const getKey = async () => {
|
@@ -58,14 +58,12 @@ const CreateMessageVerifyModal = ({ props }) => {
|
|
58
58
|
return;
|
59
59
|
}
|
60
60
|
message.success(t('sendSuccess', lang));
|
61
|
-
// 重置倒计时、验证码
|
62
61
|
setCountdown(60);
|
63
|
-
setOtp('');
|
64
62
|
};
|
65
63
|
return (_jsxs(Modal, { width: 420, visible: visible, onClose: () => {
|
66
64
|
setVisible(false);
|
67
65
|
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) => {
|
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) => {
|
69
67
|
setOtp(val);
|
70
68
|
if (val.length === 6) {
|
71
69
|
http({
|
@@ -76,16 +74,16 @@ const CreateMessageVerifyModal = ({ props }) => {
|
|
76
74
|
'sms-code-key': verifyCodeKey,
|
77
75
|
'Content-Type': config.headers['Content-Type'],
|
78
76
|
}
|
79
|
-
}).then(res => {
|
80
|
-
message.success('验证成功');
|
81
|
-
apiResolve(res);
|
82
|
-
}).catch(err => {
|
83
|
-
message.error('验证失败');
|
84
|
-
apiReject(err);
|
85
|
-
}).finally(() => {
|
86
|
-
console.log('finally');
|
87
|
-
setVisible(false);
|
88
77
|
});
|
78
|
+
console.log(config, 'config');
|
79
|
+
// const {data: {status: {code, detail} = {}}} = res;
|
80
|
+
// if(code !== 0) {
|
81
|
+
// message.error(detail || t('verifyFailed', lang));
|
82
|
+
// return;
|
83
|
+
// } else {
|
84
|
+
// message.success(t('verifySuccess', lang));
|
85
|
+
// setVisible(false);
|
86
|
+
// }
|
89
87
|
}
|
90
88
|
} }), _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
89
|
_jsxs("div", { style: { marginTop: 12, display: 'flex', alignItems: 'center' }, children: [_jsx(Input, { placeholder: t('pleaseEnterPicVerifyCode', lang), onChange: (e) => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "message-verify",
|
3
|
-
"version": "1.0.1-beta.
|
3
|
+
"version": "1.0.1-beta.2",
|
4
4
|
"type": "module",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"dependencies": {
|
@@ -29,7 +29,6 @@
|
|
29
29
|
"build": "tsc -b",
|
30
30
|
"analyze": "vite build",
|
31
31
|
"lint": "eslint .",
|
32
|
-
"preview": "vite preview"
|
33
|
-
"release:beta": "pnpm version prerelease --preid=beta && pnpm run build && pnpm publish"
|
32
|
+
"preview": "vite preview"
|
34
33
|
}
|
35
34
|
}
|
package/src/index.tsx
CHANGED
@@ -1,21 +1,18 @@
|
|
1
1
|
import ReactDOM from 'react-dom/client'
|
2
2
|
import VerifyModal from './verify-modal.js'
|
3
3
|
import Fingerprint2 from 'fingerprintjs2';
|
4
|
-
import
|
5
|
-
import { ModalConfig, LoginModalConfig } from './utils/type.js';
|
4
|
+
import { ModalConfig } from './utils/type.js';
|
6
5
|
|
7
6
|
let cachedFingerprint: string | null = null;
|
8
|
-
|
9
7
|
export const initFingerprint = async (): Promise<string> => {
|
10
|
-
if (typeof window !== 'undefined') {
|
11
|
-
const local = localStorage.getItem('__YQG_FINGERPRINT__');
|
12
|
-
if (local) return Promise.resolve(local);
|
13
|
-
}
|
14
8
|
if (cachedFingerprint) {
|
9
|
+
// 已有缓存,直接返回 Promise
|
15
10
|
return Promise.resolve(cachedFingerprint);
|
16
11
|
}
|
12
|
+
// 首次异步获取并缓存
|
17
13
|
return new Promise((resolve) => {
|
18
14
|
Fingerprint2.get(function (components) {
|
15
|
+
console.log('components', components);
|
19
16
|
const includeKeys = ['userAgent', 'deviceMemory', 'cpuClass', 'hardwareConcurrency', 'platform'];
|
20
17
|
const values = components
|
21
18
|
.filter(component => includeKeys.includes(component.key))
|
@@ -23,9 +20,6 @@ export const initFingerprint = async (): Promise<string> => {
|
|
23
20
|
.join('###');
|
24
21
|
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
25
22
|
cachedFingerprint = fingerprint;
|
26
|
-
if (typeof window !== 'undefined') {
|
27
|
-
localStorage.setItem('__YQG_FINGERPRINT__', fingerprint);
|
28
|
-
}
|
29
23
|
resolve(fingerprint);
|
30
24
|
});
|
31
25
|
});
|
@@ -52,22 +46,6 @@ export const createMessageVerifyModal = (modalProps: ModalConfig) => {
|
|
52
46
|
)
|
53
47
|
}
|
54
48
|
|
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
|
-
|
71
49
|
const destroyModal = () => {
|
72
50
|
if (modalRoot) {
|
73
51
|
modalRoot.unmount()
|
package/src/locales/en.ts
CHANGED
@@ -6,8 +6,5 @@ export default {
|
|
6
6
|
sendSuccess: 'Successfully sent',
|
7
7
|
sendFailed: 'Send failed',
|
8
8
|
reSend: 'Resend',
|
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'
|
9
|
+
countDownSecound: '{countdown} seconds'
|
13
10
|
};
|
package/src/locales/id.ts
CHANGED
@@ -6,8 +6,5 @@ export default {
|
|
6
6
|
sendSuccess: 'Berhasil dikirim',
|
7
7
|
sendFailed: 'Gagal mengirim',
|
8
8
|
reSend: 'Kirim Ulang',
|
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'
|
9
|
+
countDownSecound: '{countdown} detik'
|
13
10
|
};
|
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
|
2
|
+
import { createMessageVerifyModal, initFingerprint } 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,56 +7,51 @@ 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
|
-
"timeout": 0,
|
17
|
-
"xsrfCookieName": "XSRF-TOKEN",
|
18
|
-
"xsrfHeaderName": "X-XSRF-TOKEN",
|
19
|
-
"maxContentLength": -1,
|
20
|
-
"maxBodyLength": -1,
|
21
|
-
"headers": {
|
22
|
-
"Accept": "application/json, text/plain, */*",
|
23
|
-
"X-Device-Fingerprint": "185fcce88c629725321adf29daa5e444",
|
24
|
-
"Content-Type": "application/json"
|
25
|
-
},
|
26
|
-
"url": "/classification/admin/level/edit",
|
27
|
-
"method": "post",
|
28
|
-
"dataFormat": "JSON",
|
29
|
-
"showRequestData": true,
|
30
|
-
"showResponseData": false,
|
31
|
-
"showGeneralResponseData": true,
|
32
|
-
"headersList": [],
|
33
|
-
"requestDataFunc": "\nfunction(formFilterData){\n // 这里写你的处理逻辑\n return {\n ...formFilterData,\n 'classificationLevel': 2 //等级\n }\n}\n",
|
34
|
-
"responseDataFunc": "",
|
35
|
-
"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}",
|
36
|
-
"formInstance": {},
|
37
|
-
"data": "{\"id\":1,\"classificationName\":\"个人基本概况信息\",\"classificationLevel\":2}",
|
38
|
-
"baseURL": "http://localhost:62888"
|
39
|
-
};
|
40
10
|
createRoot(document.getElementById('root')!).render(
|
41
11
|
<>
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
12
|
+
<button onClick={() => createMessageVerifyModal({
|
13
|
+
data,
|
14
|
+
config: {
|
15
|
+
"transitional": {
|
16
|
+
"silentJSONParsing": true,
|
17
|
+
"forcedJSONParsing": true,
|
18
|
+
"clarifyTimeoutError": false
|
19
|
+
},
|
20
|
+
"transformRequest": [
|
21
|
+
null
|
22
|
+
],
|
23
|
+
"transformResponse": [
|
24
|
+
null
|
25
|
+
],
|
26
|
+
"timeout": 0,
|
27
|
+
"xsrfCookieName": "XSRF-TOKEN",
|
28
|
+
"xsrfHeaderName": "X-XSRF-TOKEN",
|
29
|
+
"maxContentLength": -1,
|
30
|
+
"maxBodyLength": -1,
|
31
|
+
"headers": {
|
32
|
+
"Accept": "application/json, text/plain, */*",
|
33
|
+
"X-Device-Fingerprint": "185fcce88c629725321adf29daa5e444",
|
34
|
+
"Content-Type": "application/json",
|
35
|
+
"sms-code": "121212",
|
36
|
+
"sms-code-key": "212190c7-2f5e-4cc1-82ec-a242c2ab5425"
|
37
|
+
},
|
38
|
+
"url": "/classification/admin/level/edit",
|
39
|
+
"method": "post",
|
40
|
+
"dataFormat": "JSON",
|
41
|
+
"showRequestData": true,
|
42
|
+
"showResponseData": false,
|
43
|
+
"showGeneralResponseData": true,
|
44
|
+
"headersList": [],
|
45
|
+
"requestDataFunc": "\nfunction(formFilterData){\n // 这里写你的处理逻辑\n return {\n ...formFilterData,\n 'classificationLevel': 2 //等级\n }\n}\n",
|
46
|
+
"responseDataFunc": "",
|
47
|
+
"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}",
|
48
|
+
"formInstance": {},
|
49
|
+
"data": "{\"id\":1,\"classificationName\":\"个人基本概况信息\",\"classificationLevel\":2}",
|
50
|
+
"baseURL": "http://localhost:62888"
|
51
|
+
},
|
52
|
+
lang: 'en',
|
53
|
+
http: axios,
|
54
|
+
})}>
|
55
|
+
Show verify Modal
|
56
|
+
</button>
|
62
57
|
</>);
|
package/src/relogin-modal.tsx
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
import { useState } from 'react'
|
2
2
|
import { Modal, Button } from './compoments/index.js'
|
3
|
-
import {
|
4
|
-
import t from './utils/i18n.js'
|
3
|
+
import { ModalConfig } from './utils/type.js';
|
5
4
|
|
6
|
-
const ReLoginModal = ({ props }: { props:
|
7
|
-
|
5
|
+
const ReLoginModal = ({ props }: { props: ModalConfig }) => {
|
6
|
+
console.log('props', props);
|
8
7
|
const [visible, setVisible] = useState(true);
|
9
8
|
const onClose = () => {
|
10
9
|
setVisible(false);
|
11
|
-
goLogin();
|
12
10
|
};
|
13
11
|
return (
|
14
12
|
<Modal visible={visible} onClose={onClose} width={420}>
|
15
13
|
<div style={{ fontWeight: 500, fontSize: 20, marginBottom: 24 }}>
|
16
|
-
|
14
|
+
账号安全提醒
|
17
15
|
</div>
|
18
16
|
<div style={{ color: '#222', fontSize: 16, marginBottom: 40, lineHeight: '24px' }}>
|
19
|
-
|
17
|
+
检测到您的登录环境或网络信息有变动,为保障账户安全,请重新登录验证身份
|
20
18
|
</div>
|
21
19
|
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
22
20
|
<Button
|
@@ -24,15 +22,16 @@ const ReLoginModal = ({ props }: { props: LoginModalConfig }) => {
|
|
24
22
|
background: '#1677ff',
|
25
23
|
color: '#fff',
|
26
24
|
border: 'none',
|
27
|
-
width:
|
28
|
-
height:
|
29
|
-
fontSize:
|
25
|
+
width: 160,
|
26
|
+
height: 44,
|
27
|
+
fontSize: 18,
|
28
|
+
fontWeight: 500,
|
30
29
|
borderRadius: 8,
|
31
30
|
boxShadow: '0 2px 8px rgba(22,119,255,0.08)',
|
32
31
|
}}
|
33
32
|
onClick={onClose}
|
34
33
|
>
|
35
|
-
|
34
|
+
好的
|
36
35
|
</Button>
|
37
36
|
</div>
|
38
37
|
</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,11 +20,4 @@ export type ModalConfig = {
|
|
20
20
|
}
|
21
21
|
};
|
22
22
|
api?: string;
|
23
|
-
apiReject: any;
|
24
|
-
apiResolve: any;
|
25
|
-
}
|
26
|
-
|
27
|
-
export type LoginModalConfig = {
|
28
|
-
goLogin: () => void;
|
29
|
-
lang?: 'zh' | 'en' | 'id';
|
30
23
|
}
|
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'
|
15
|
+
const { data, config, http, lang, api='/admin/sms/send' } = props || {};
|
16
16
|
const dataObj = JSON.parse(data || '{}');
|
17
17
|
const { mobile, verifyCodeKey } = dataObj || {};
|
18
18
|
|
@@ -60,9 +60,7 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
60
60
|
return;
|
61
61
|
}
|
62
62
|
message.success(t('sendSuccess', lang));
|
63
|
-
// 重置倒计时、验证码
|
64
63
|
setCountdown(60);
|
65
|
-
setOtp('');
|
66
64
|
}
|
67
65
|
|
68
66
|
return (
|
@@ -80,7 +78,7 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
80
78
|
<Input.OTP
|
81
79
|
length={6}
|
82
80
|
value={otp}
|
83
|
-
onChange={(val) => {
|
81
|
+
onChange={async (val) => {
|
84
82
|
setOtp(val);
|
85
83
|
if (val.length === 6) {
|
86
84
|
http({
|
@@ -91,16 +89,16 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
91
89
|
'sms-code-key': verifyCodeKey,
|
92
90
|
'Content-Type': config.headers['Content-Type'],
|
93
91
|
}
|
94
|
-
})
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
}
|
101
|
-
|
102
|
-
|
103
|
-
}
|
92
|
+
}) as any;
|
93
|
+
console.log(config, 'config');
|
94
|
+
// const {data: {status: {code, detail} = {}}} = res;
|
95
|
+
// if(code !== 0) {
|
96
|
+
// message.error(detail || t('verifyFailed', lang));
|
97
|
+
// return;
|
98
|
+
// } else {
|
99
|
+
// message.success(t('verifySuccess', lang));
|
100
|
+
// setVisible(false);
|
101
|
+
// }
|
104
102
|
}
|
105
103
|
}} />
|
106
104
|
<Button
|