message-verify 0.0.52-beta.0 → 1.0.0-beta.1

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/main.js CHANGED
@@ -1,16 +1,11 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createRoot } from 'react-dom/client';
3
3
  import { createMessageVerifyModal } from './index.js'; // 或 './index'
4
+ import { axios } from '@yqg/resource';
4
5
  const data = "{\"mobile\":\"188****4035\",\"verifyCodeKey\":\"3f025b33-988e-47c0-950d-6beb776d043f\",\"needValid\":true,\"step\":2,\"message\":\"需要填写验证码\"}";
5
6
  createRoot(document.getElementById('root')).render(_jsx("button", { onClick: () => createMessageVerifyModal({
6
7
  data,
7
8
  config: {},
8
9
  lang: 'en',
9
- http: Object.assign(() => Promise.resolve({}), {
10
- defaults: {
11
- headers: {
12
- common: {}
13
- }
14
- }
15
- }),
10
+ http: axios,
16
11
  }), children: "Show Modal" }));
@@ -47,7 +47,10 @@ const CreateMessageVerifyModal = ({ props }) => {
47
47
  }, [visible, countdown]);
48
48
  const handleResend = async () => {
49
49
  setCountdown(60);
50
- const res = await Api.reSendCode({ captchaKey, captcha: captchCode });
50
+ const formData = new FormData();
51
+ formData.append('captchaKey', captchaKey);
52
+ formData.append('captcha', captchCode);
53
+ const res = await Api.reSendCode(formData);
51
54
  console.log('handleResend=>res', res);
52
55
  message.success(t('sendSuccess', lang));
53
56
  };
@@ -57,9 +60,15 @@ const CreateMessageVerifyModal = ({ props }) => {
57
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) => {
58
61
  setOtp(val);
59
62
  if (val.length === 6) {
60
- http.defaults.headers.common['sms-code'] = val;
61
- http.defaults.headers.common['sms-code-key'] = verifyCodeKey;
62
- http(config);
63
+ console.log('otp', val);
64
+ http({
65
+ ...config,
66
+ headers: {
67
+ ...http.defaults.headers.common,
68
+ 'sms-code': val,
69
+ 'sms-code-key': verifyCodeKey,
70
+ }
71
+ });
63
72
  setVisible(false);
64
73
  }
65
74
  } }), _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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "message-verify",
3
- "version": "0.0.52-beta.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
package/src/main.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createRoot } from 'react-dom/client';
2
2
  import { createMessageVerifyModal } from './index.js'; // 或 './index'
3
+ import { axios } from '@yqg/resource';
3
4
 
4
5
  const data = "{\"mobile\":\"188****4035\",\"verifyCodeKey\":\"3f025b33-988e-47c0-950d-6beb776d043f\",\"needValid\":true,\"step\":2,\"message\":\"需要填写验证码\"}";
5
6
 
@@ -8,16 +9,7 @@ createRoot(document.getElementById('root')!).render(
8
9
  data,
9
10
  config: {},
10
11
  lang: 'en',
11
- http: Object.assign(
12
- () => Promise.resolve({}),
13
- {
14
- defaults: {
15
- headers: {
16
- common: {}
17
- }
18
- }
19
- }
20
- ),
12
+ http: axios,
21
13
  })}>
22
14
  Show Modal
23
15
  </button>);
@@ -64,7 +64,10 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
64
64
 
65
65
  const handleResend = async () => {
66
66
  setCountdown(60);
67
- const res = await Api.reSendCode({ captchaKey, captcha: captchCode });
67
+ const formData = new FormData();
68
+ formData.append('captchaKey', captchaKey);
69
+ formData.append('captcha', captchCode);
70
+ const res = await Api.reSendCode(formData);
68
71
  console.log('handleResend=>res', res);
69
72
  message.success(t('sendSuccess', lang));
70
73
  }
@@ -87,9 +90,15 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
87
90
  onChange={(val) => {
88
91
  setOtp(val);
89
92
  if (val.length === 6) {
90
- http.defaults.headers.common['sms-code'] = val as string;
91
- http.defaults.headers.common['sms-code-key'] = verifyCodeKey as string;
92
- http(config);
93
+ console.log('otp', val);
94
+ http({
95
+ ...config,
96
+ headers: {
97
+ ...http.defaults.headers.common,
98
+ 'sms-code': val,
99
+ 'sms-code-key': verifyCodeKey,
100
+ }
101
+ });
93
102
  setVisible(false);
94
103
  }
95
104
  }} />