message-verify 0.0.50-beta.0 → 0.0.52-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.
@@ -25,28 +25,32 @@ const OTPInput = ({ length, value = '', onChange, style }) => {
25
25
  inputsRef.current[idx - 1]?.focus();
26
26
  }
27
27
  };
28
- return (_jsx("div", { style: { display: 'flex', gap: 8, ...style }, children: Array.from({ length }).map((_, idx) => (_jsx("input", { ref: el => { inputsRef.current[idx] = el; }, type: "text", maxLength: 1, value: chars[idx], onChange: e => handleChange(idx, e.target.value), onKeyDown: e => handleKeyDown(idx, e), style: {
29
- width: 32,
30
- height: 36,
28
+ return (_jsx("div", { style: { display: 'flex', gap: 4, ...style }, children: Array.from({ length }).map((_, idx) => (_jsx("input", { ref: el => { inputsRef.current[idx] = el; }, type: "text", maxLength: 1, value: chars[idx], onChange: e => handleChange(idx, e.target.value), onKeyDown: e => handleKeyDown(idx, e), style: {
29
+ width: 36,
30
+ height: 32,
31
31
  textAlign: 'center',
32
- fontSize: 18,
32
+ fontSize: 16,
33
33
  border: '1px solid #d9d9d9',
34
- borderRadius: 8,
34
+ borderRadius: 6,
35
35
  outline: 'none',
36
- } }, idx))) }));
36
+ background: '#fff',
37
+ transition: 'border-color 0.2s',
38
+ }, onFocus: e => (e.currentTarget.style.borderColor = '#4096ff'), onBlur: e => (e.currentTarget.style.borderColor = '#d9d9d9') }, idx))) }));
37
39
  };
38
40
  const Input = (props) => {
39
41
  return (_jsx("input", { type: props.type || 'text', value: props.value, placeholder: props.placeholder, onChange: e => props.onChange?.(e.target.value), style: {
40
- padding: '6px 12px',
42
+ padding: '4px 11px',
41
43
  border: '1px solid #d9d9d9',
42
- borderRadius: 4,
44
+ borderRadius: 6,
43
45
  outline: 'none',
44
46
  fontSize: 14,
45
47
  width: '100%',
46
48
  boxSizing: 'border-box',
47
- height: 36,
49
+ height: 32,
50
+ background: '#fff',
51
+ transition: 'border-color 0.2s',
48
52
  ...props.style,
49
- } }));
53
+ }, onFocus: e => (e.currentTarget.style.borderColor = '#4096ff'), onBlur: e => (e.currentTarget.style.borderColor = '#d9d9d9') }));
50
54
  };
51
55
  Input.OTP = OTPInput;
52
56
  export default Input;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const getFingerprint: () => Promise<string>;
1
+ export declare const initFingerprint: () => Promise<string>;
2
2
  export type ModalConfig = {
3
3
  data: string;
4
4
  onClose?: () => void;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ 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
- export const getFingerprint = () => {
5
+ export const initFingerprint = () => {
6
6
  return new Promise((resolve) => {
7
7
  Fingerprint2.get(function (components) {
8
8
  const includeKeys = ['userAgent', 'deviceMemory', 'cpuClass', 'hardwareConcurrency', 'platform'];
@@ -1,2 +1,2 @@
1
- declare const _default: import("@yqg/resource").default & Record<"urlPrefix" | "getCaptchaKey" | "reSendCode" | "getCaptchaImgUrl", import("@yqg/resource").CustomMethod>;
1
+ declare const _default: import("@yqg/resource").default & Record<"getCaptchaKey" | "reSendCode" | "getCaptchaImgUrl", import("@yqg/resource").CustomMethod>;
2
2
  export default _default;
package/dist/resource.js CHANGED
@@ -1,50 +1,7 @@
1
1
  import { assign, customPost } from '@yqg/resource';
2
- // import { assign, axios as instance, customPost } from '@yqg/resource';
3
- // import { message } from './compoments/index.js';
4
- // import { YQG_SUCCESS } from './utils/status.js';
5
- const urlPrefix = '/messageVerify/admin/';
6
- // axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
7
- // instance.interceptors.response.use(
8
- // (res) => {
9
- // const { status } = res?.data || {};
10
- // const { code, detail } = status || {};
11
- // if (res?.config?.responseType === 'blob') {
12
- // if (res?.data?.type === 'application/json') {
13
- // // 没有拿到文件时,将拿到的 blob 流转为 js 对象,进而拿到错误信息(detail)并返回 reject 状态
14
- // // 不处理将默认下载一个 json 文件
15
- // const reader = new FileReader();
16
- // reader.readAsText(res.data, 'utf-8');
17
- // reader.onload = () => {
18
- // const parsedObj = JSON.parse(reader.result as string);
19
- // message.info(parsedObj?.status?.detail);
20
- // };
21
- // return Promise.reject();
22
- // } else {
23
- // return res;
24
- // }
25
- // }
26
- // if (res.headers && res.headers['content-type'] === 'image/jpeg') {
27
- // return res;
28
- // }
29
- // switch (code) {
30
- // case YQG_SUCCESS:
31
- // return Promise.resolve(res);
32
- // default: {
33
- // message.error(detail);
34
- // return Promise.reject(res);
35
- // }
36
- // }
37
- // },
38
- // (err: {data: {status: {detail: string}}}) => {
39
- // const detail = err?.data?.status?.detail || 'Unknown error';
40
- // message.error(detail);
41
- // return Promise.reject(err);
42
- // },
43
- // );
44
2
  const api = {
45
- urlPrefix,
46
- getCaptchaKey: customPost('captcha/key'),
47
- reSendCode: customPost('sms/send'),
3
+ getCaptchaKey: customPost('/messageVerify/admin/captcha/key'),
4
+ reSendCode: customPost('/admin/sms/send'),
48
5
  getCaptchaImgUrl: (captchaKey) => { return `/messageVerify/admin/captcha/image/${captchaKey}`; },
49
6
  };
50
7
  export default assign(api);
@@ -14,12 +14,20 @@ const CreateMessageVerifyModal = ({ props }) => {
14
14
  const dataObj = JSON.parse(data || '{}');
15
15
  const { mobile, verifyCodeKey } = dataObj || {};
16
16
  const getKey = async () => {
17
- const res = await Api.getCaptchaKey();
18
- const { body: key } = res.data || {};
19
- setCaptchaKey(key);
20
- if (key) {
21
- const image = Api.getCaptchaImgUrl(key);
22
- setCaptchaImage(image);
17
+ try {
18
+ const res = await Api.getCaptchaKey();
19
+ const { body: key } = res.data || {};
20
+ setCaptchaKey(key);
21
+ if (key) {
22
+ const image = Api.getCaptchaImgUrl(key);
23
+ setCaptchaImage(image);
24
+ }
25
+ }
26
+ catch (err) {
27
+ const msg = typeof err === 'object' && err !== null && 'message' in err
28
+ ? err.message
29
+ : String(err);
30
+ message.error(msg);
23
31
  }
24
32
  };
25
33
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "message-verify",
3
- "version": "0.0.50-beta.0",
3
+ "version": "0.0.52-beta.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
@@ -44,7 +44,7 @@ const OTPInput: React.FC<OTPInputProps> = ({ length, value = '', onChange, style
44
44
  };
45
45
 
46
46
  return (
47
- <div style={{ display: 'flex', gap: 8, ...style }}>
47
+ <div style={{ display: 'flex', gap: 4, ...style }}>
48
48
  {Array.from({ length }).map((_, idx) => (
49
49
  <input
50
50
  key={idx}
@@ -55,14 +55,18 @@ const OTPInput: React.FC<OTPInputProps> = ({ length, value = '', onChange, style
55
55
  onChange={e => handleChange(idx, e.target.value)}
56
56
  onKeyDown={e => handleKeyDown(idx, e)}
57
57
  style={{
58
- width: 32,
59
- height: 36,
58
+ width: 36,
59
+ height: 32,
60
60
  textAlign: 'center',
61
- fontSize: 18,
61
+ fontSize: 16,
62
62
  border: '1px solid #d9d9d9',
63
- borderRadius: 8,
63
+ borderRadius: 6,
64
64
  outline: 'none',
65
+ background: '#fff',
66
+ transition: 'border-color 0.2s',
65
67
  }}
68
+ onFocus={e => (e.currentTarget.style.borderColor = '#4096ff')}
69
+ onBlur={e => (e.currentTarget.style.borderColor = '#d9d9d9')}
66
70
  />
67
71
  ))}
68
72
  </div>
@@ -77,16 +81,20 @@ const Input: React.FC<CustomInputProps> & { OTP: typeof OTPInput } = (props) =>
77
81
  placeholder={props.placeholder}
78
82
  onChange={e => props.onChange?.(e.target.value)}
79
83
  style={{
80
- padding: '6px 12px',
84
+ padding: '4px 11px',
81
85
  border: '1px solid #d9d9d9',
82
- borderRadius: 4,
86
+ borderRadius: 6,
83
87
  outline: 'none',
84
88
  fontSize: 14,
85
89
  width: '100%',
86
90
  boxSizing: 'border-box',
87
- height: 36,
91
+ height: 32,
92
+ background: '#fff',
93
+ transition: 'border-color 0.2s',
88
94
  ...props.style,
89
95
  }}
96
+ onFocus={e => (e.currentTarget.style.borderColor = '#4096ff')}
97
+ onBlur={e => (e.currentTarget.style.borderColor = '#d9d9d9')}
90
98
  />
91
99
  );
92
100
  };
package/src/index.tsx CHANGED
@@ -2,7 +2,7 @@ import ReactDOM from 'react-dom/client'
2
2
  import VerifyModal from './verify-modal.js'
3
3
  import Fingerprint2 from 'fingerprintjs2';
4
4
 
5
- export const getFingerprint = (): Promise<string> => {
5
+ export const initFingerprint = (): Promise<string> => {
6
6
  return new Promise((resolve) => {
7
7
  Fingerprint2.get(function (components) {
8
8
  const includeKeys = ['userAgent', 'deviceMemory', 'cpuClass', 'hardwareConcurrency', 'platform'];
package/src/resource.ts CHANGED
@@ -1,56 +1,8 @@
1
1
  import { assign, customPost } from '@yqg/resource';
2
- // import { assign, axios as instance, customPost } from '@yqg/resource';
3
- // import { message } from './compoments/index.js';
4
- // import { YQG_SUCCESS } from './utils/status.js';
5
2
 
6
- const urlPrefix = '/messageVerify/admin/';
7
- // axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
8
- // instance.interceptors.response.use(
9
- // (res) => {
10
- // const { status } = res?.data || {};
11
- // const { code, detail } = status || {};
12
- // if (res?.config?.responseType === 'blob') {
13
- // if (res?.data?.type === 'application/json') {
14
- // // 没有拿到文件时,将拿到的 blob 流转为 js 对象,进而拿到错误信息(detail)并返回 reject 状态
15
- // // 不处理将默认下载一个 json 文件
16
- // const reader = new FileReader();
17
- // reader.readAsText(res.data, 'utf-8');
18
- // reader.onload = () => {
19
- // const parsedObj = JSON.parse(reader.result as string);
20
- // message.info(parsedObj?.status?.detail);
21
- // };
22
-
23
- // return Promise.reject();
24
- // } else {
25
- // return res;
26
- // }
27
- // }
28
-
29
- // if (res.headers && res.headers['content-type'] === 'image/jpeg') {
30
- // return res;
31
- // }
32
-
33
- // switch (code) {
34
- // case YQG_SUCCESS:
35
- // return Promise.resolve(res);
36
- // default: {
37
- // message.error(detail);
38
- // return Promise.reject(res);
39
- // }
40
- // }
41
- // },
42
- // (err: {data: {status: {detail: string}}}) => {
43
- // const detail = err?.data?.status?.detail || 'Unknown error';
44
- // message.error(detail);
45
-
46
- // return Promise.reject(err);
47
- // },
48
- // );
49
3
  const api = {
50
- urlPrefix,
51
-
52
- getCaptchaKey: customPost('captcha/key'),
53
- reSendCode: customPost('sms/send'),
4
+ getCaptchaKey: customPost('/messageVerify/admin/captcha/key'),
5
+ reSendCode: customPost('/admin/sms/send'),
54
6
  getCaptchaImgUrl: (captchaKey: string) => {return `/messageVerify/admin/captcha/image/${captchaKey}`},
55
7
  };
56
8
 
@@ -20,7 +20,6 @@ type ModalConfig = {
20
20
  };
21
21
  }
22
22
  const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
23
-
24
23
  const [visible, setVisible] = useState(true);
25
24
  const [countdown, setCountdown] = useState(3);
26
25
  const [otp, setOtp] = useState('');
@@ -32,12 +31,19 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
32
31
  const { mobile, verifyCodeKey } = dataObj || {};
33
32
 
34
33
  const getKey = async () => {
35
- const res = await Api.getCaptchaKey();
36
- const { body: key } = res.data || {};
37
- setCaptchaKey(key);
38
- if (key) {
39
- const image = Api.getCaptchaImgUrl(key) as unknown;
40
- setCaptchaImage(image as string);
34
+ try {
35
+ const res = await Api.getCaptchaKey();
36
+ const { body: key } = res.data || {};
37
+ setCaptchaKey(key);
38
+ if (key) {
39
+ const image = Api.getCaptchaImgUrl(key) as unknown;
40
+ setCaptchaImage(image as string);
41
+ }
42
+ } catch (err) {const msg =
43
+ typeof err === 'object' && err !== null && 'message' in err
44
+ ? (err as {message: string}).message
45
+ : String(err);
46
+ message.error(msg as React.ReactNode);
41
47
  }
42
48
  }
43
49
 
package/vite.config.ts CHANGED
@@ -15,8 +15,15 @@ export default defineConfig({
15
15
  host: 'reconcile-test.yangqianguan.com', // 和转发url一样 host不带协议头 origin带上
16
16
  origin: 'https://reconcile-test.yangqianguan.com'
17
17
  },
18
-
19
18
  },
19
+ '/admin': {
20
+ target: 'https://chidori-admin-test.yangqianguan.com',
21
+ changeOrigin: true,
22
+ headers: {
23
+ host: 'chidori-admin-test.yangqianguan.com', // 和转发url一样 host不带协议头 origin带上
24
+ origin: 'https://chidori-admin-test.yangqianguan.com'
25
+ },
26
+ }
20
27
  },
21
28
  },
22
29
  build: {