message-verify 1.0.0-beta.1 → 1.0.0-beta.3

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 CHANGED
@@ -1,18 +1,3 @@
1
+ import { ModalConfig } from './utils/type.js';
1
2
  export declare const initFingerprint: () => Promise<string>;
2
- export type ModalConfig = {
3
- data: string;
4
- onClose?: () => void;
5
- config: object;
6
- lang: 'zh' | 'en' | 'id';
7
- http: {
8
- (params: object): Promise<unknown>;
9
- defaults: {
10
- headers: {
11
- common: {
12
- [key: string]: unknown;
13
- };
14
- };
15
- };
16
- };
17
- };
18
3
  export declare const createMessageVerifyModal: (modalProps: ModalConfig) => void;
package/dist/main.js CHANGED
@@ -5,7 +5,7 @@ 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
  createRoot(document.getElementById('root')).render(_jsx("button", { onClick: () => createMessageVerifyModal({
7
7
  data,
8
- config: {},
8
+ config: { headers: {} },
9
9
  lang: 'en',
10
10
  http: axios,
11
11
  }), children: "Show Modal" }));
@@ -1 +1 @@
1
- {"root":["../src/index.tsx","../src/main.tsx","../src/resource.ts","../src/verify-modal.tsx","../src/vite-env.d.ts","../src/compoments/button.tsx","../src/compoments/index.ts","../src/compoments/input.tsx","../src/compoments/message.tsx","../src/compoments/modal.tsx","../src/locales/en.ts","../src/locales/id.ts","../src/locales/zh.ts","../src/utils/i18n.ts","../src/utils/status.ts"],"version":"5.7.3"}
1
+ {"root":["../src/index.tsx","../src/main.tsx","../src/resource.ts","../src/verify-modal.tsx","../src/vite-env.d.ts","../src/compoments/button.tsx","../src/compoments/index.ts","../src/compoments/input.tsx","../src/compoments/message.tsx","../src/compoments/modal.tsx","../src/locales/en.ts","../src/locales/id.ts","../src/locales/zh.ts","../src/utils/i18n.ts","../src/utils/status.ts","../src/utils/type.ts"],"version":"5.7.3"}
@@ -0,0 +1,21 @@
1
+ export type ModalConfig = {
2
+ data: string;
3
+ onClose?: () => void;
4
+ config: {
5
+ headers: {
6
+ [key: string]: string | undefined;
7
+ };
8
+ [key: string]: unknown;
9
+ };
10
+ lang: 'zh' | 'en' | 'id';
11
+ http: {
12
+ (params: object): Promise<unknown>;
13
+ defaults: {
14
+ headers: {
15
+ common: {
16
+ [key: string]: unknown;
17
+ };
18
+ };
19
+ };
20
+ };
21
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,19 +1,4 @@
1
- type ModalConfig = {
2
- data: string;
3
- onClose?: () => void;
4
- config: object;
5
- lang: 'zh' | 'en' | 'id';
6
- http: {
7
- (params: object): Promise<unknown>;
8
- defaults: {
9
- headers: {
10
- common: {
11
- [key: string]: unknown;
12
- };
13
- };
14
- };
15
- };
16
- };
1
+ import { ModalConfig } from './utils/type.js';
17
2
  declare const CreateMessageVerifyModal: ({ props }: {
18
3
  props: ModalConfig;
19
4
  }) => import("react/jsx-runtime.js").JSX.Element;
@@ -50,8 +50,8 @@ const CreateMessageVerifyModal = ({ props }) => {
50
50
  const formData = new FormData();
51
51
  formData.append('captchaKey', captchaKey);
52
52
  formData.append('captcha', captchCode);
53
- const res = await Api.reSendCode(formData);
54
- console.log('handleResend=>res', res);
53
+ // 重新发送验证码
54
+ await Api.reSendCode(formData);
55
55
  message.success(t('sendSuccess', lang));
56
56
  };
57
57
  return (_jsxs(Modal, { width: 420, visible: visible, onClose: () => {
@@ -59,14 +59,15 @@ const CreateMessageVerifyModal = ({ props }) => {
59
59
  props.onClose?.();
60
60
  }, 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) => {
61
61
  setOtp(val);
62
+ console.log('打印Content-Type', config.headers['Content-Type']);
62
63
  if (val.length === 6) {
63
- console.log('otp', val);
64
64
  http({
65
65
  ...config,
66
66
  headers: {
67
67
  ...http.defaults.headers.common,
68
68
  'sms-code': val,
69
69
  'sms-code-key': verifyCodeKey,
70
+ 'Content-Type': config.headers['Content-Type'],
70
71
  }
71
72
  });
72
73
  setVisible(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "message-verify",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
package/src/index.tsx CHANGED
@@ -1,6 +1,7 @@
1
1
  import ReactDOM from 'react-dom/client'
2
2
  import VerifyModal from './verify-modal.js'
3
3
  import Fingerprint2 from 'fingerprintjs2';
4
+ import { ModalConfig } from './utils/type.js';
4
5
 
5
6
  export const initFingerprint = (): Promise<string> => {
6
7
  return new Promise((resolve) => {
@@ -16,23 +17,6 @@ export const initFingerprint = (): Promise<string> => {
16
17
  });
17
18
  };
18
19
 
19
- export type ModalConfig = {
20
- data: string;
21
- onClose?: () => void
22
- config: object;
23
- lang: 'zh' | 'en' | 'id';
24
- http: {
25
- (params: object): Promise<unknown>;
26
- defaults: {
27
- headers: {
28
- common: {
29
- [key: string]: unknown;
30
- }
31
- }
32
- }
33
- };
34
- }
35
-
36
20
  let modalRoot: ReactDOM.Root | null = null
37
21
 
38
22
  export const createMessageVerifyModal = (modalProps: ModalConfig) => {
package/src/main.tsx CHANGED
@@ -7,7 +7,7 @@ const data = "{\"mobile\":\"188****4035\",\"verifyCodeKey\":\"3f025b33-988e-47c0
7
7
  createRoot(document.getElementById('root')!).render(
8
8
  <button onClick={() => createMessageVerifyModal({
9
9
  data,
10
- config: {},
10
+ config: {headers: {}},
11
11
  lang: 'en',
12
12
  http: axios,
13
13
  })}>
@@ -0,0 +1,22 @@
1
+
2
+ export type ModalConfig = {
3
+ data: string;
4
+ onClose?: () => void
5
+ config: {
6
+ headers: {
7
+ [key: string]: string | undefined;
8
+ };
9
+ [key: string]: unknown;
10
+ };
11
+ lang: 'zh' | 'en' | 'id';
12
+ http: {
13
+ (params: object): Promise<unknown>;
14
+ defaults: {
15
+ headers: {
16
+ common: {
17
+ [key: string]: unknown;
18
+ }
19
+ }
20
+ }
21
+ };
22
+ }
@@ -2,23 +2,8 @@ import { useEffect, useState } from 'react'
2
2
  import { Modal, Input, Button, message } from './compoments/index.js'
3
3
  import Api from './resource.js'
4
4
  import t from './utils/i18n.js'
5
+ import { ModalConfig } from './utils/type.js';
5
6
 
6
- type ModalConfig = {
7
- data: string;
8
- onClose?: () => void;
9
- config: object;
10
- lang: 'zh' | 'en' | 'id';
11
- http: {
12
- (params: object): Promise<unknown>;
13
- defaults: {
14
- headers: {
15
- common: {
16
- [key: string]: unknown;
17
- }
18
- }
19
- }
20
- };
21
- }
22
7
  const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
23
8
  const [visible, setVisible] = useState(true);
24
9
  const [countdown, setCountdown] = useState(3);
@@ -67,8 +52,8 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
67
52
  const formData = new FormData();
68
53
  formData.append('captchaKey', captchaKey);
69
54
  formData.append('captcha', captchCode);
70
- const res = await Api.reSendCode(formData);
71
- console.log('handleResend=>res', res);
55
+ // 重新发送验证码
56
+ await Api.reSendCode(formData);
72
57
  message.success(t('sendSuccess', lang));
73
58
  }
74
59
 
@@ -89,14 +74,15 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
89
74
  value={otp}
90
75
  onChange={(val) => {
91
76
  setOtp(val);
77
+ console.log('打印Content-Type', config.headers['Content-Type'])
92
78
  if (val.length === 6) {
93
- console.log('otp', val);
94
79
  http({
95
80
  ...config,
96
81
  headers: {
97
82
  ...http.defaults.headers.common,
98
83
  'sms-code': val,
99
84
  'sms-code-key': verifyCodeKey,
85
+ 'Content-Type': config.headers['Content-Type'],
100
86
  }
101
87
  });
102
88
  setVisible(false);