message-verify 1.0.1-beta.17 → 1.0.1-beta.18

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
@@ -11,12 +11,6 @@ const config = {
11
11
  "forcedJSONParsing": true,
12
12
  "clarifyTimeoutError": false
13
13
  },
14
- // "transformRequest": [
15
- // null
16
- // ],
17
- // "transformResponse": [
18
- // null
19
- // ],
20
14
  "timeout": 0,
21
15
  "xsrfCookieName": "XSRF-TOKEN",
22
16
  "xsrfHeaderName": "X-XSRF-TOKEN",
@@ -44,14 +38,11 @@ const config = {
44
38
  createRoot(document.getElementById('root')).render(_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => createMessageVerifyModal({
45
39
  data,
46
40
  config,
47
- response: {
48
- config
49
- },
50
41
  lang: 'en',
51
42
  http: axios,
52
- myReject: () => {
43
+ apiReject: () => {
53
44
  },
54
- myResolve: () => {
45
+ apiResolve: () => {
55
46
  }
56
47
  }), children: "Show verify Modal" }), _jsx("button", { onClick: () => createReLoginModal({
57
48
  goLogin: () => {
@@ -19,9 +19,8 @@ export type ModalConfig = {
19
19
  };
20
20
  };
21
21
  api?: string;
22
- response: any;
23
- myReject: any;
24
- myResolve: any;
22
+ apiReject: any;
23
+ apiResolve: any;
25
24
  };
26
25
  export type LoginModalConfig = {
27
26
  goLogin: () => void;
@@ -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', config, myResolve, myReject } = props || {};
14
+ const { data, http, lang, api = '/admin/sms/send', config, apiResolve, apiReject } = props || {};
15
15
  const dataObj = JSON.parse(data || '{}');
16
16
  const { mobile, verifyCodeKey } = dataObj || {};
17
17
  const getKey = async () => {
@@ -65,10 +65,9 @@ const CreateMessageVerifyModal = ({ props }) => {
65
65
  return (_jsxs(Modal, { width: 420, visible: visible, onClose: () => {
66
66
  setVisible(false);
67
67
  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: async (val) => {
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) => {
69
69
  setOtp(val);
70
70
  if (val.length === 6) {
71
- // try {
72
71
  http({
73
72
  ...config,
74
73
  headers: {
@@ -78,21 +77,12 @@ const CreateMessageVerifyModal = ({ props }) => {
78
77
  'Content-Type': config.headers['Content-Type'],
79
78
  }
80
79
  }).then(res => {
81
- setVisible(false);
82
- myResolve(res);
83
- // return res;
80
+ apiResolve(res);
84
81
  }).catch(err => {
85
- myReject(err);
82
+ apiReject(err);
83
+ }).finally(() => {
84
+ setVisible(false);
86
85
  });
87
- // console.log('组件打印res', res);
88
- // if(!res) {
89
- // message.error('验证失败');
90
- // } else {
91
- // message.success('验证成功');
92
- // }
93
- // } catch (error: any) {
94
- // message.error(error?.message || t('sendFailed', lang));
95
- // }
96
86
  }
97
87
  } }), _jsx(Button, { disabled: countdown > 0 || !captchCode, onClick: handleResend, style: { padding: '8px' }, children: countdown > 0 ? t('countDownSecound', lang, { countdown }) : t('reSend', lang) })] }), countdown > 0 ? null :
98
88
  _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.17",
3
+ "version": "1.0.1-beta.18",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
package/src/main.tsx CHANGED
@@ -13,12 +13,6 @@ const config = {
13
13
  "forcedJSONParsing": true,
14
14
  "clarifyTimeoutError": false
15
15
  },
16
- // "transformRequest": [
17
- // null
18
- // ],
19
- // "transformResponse": [
20
- // null
21
- // ],
22
16
  "timeout": 0,
23
17
  "xsrfCookieName": "XSRF-TOKEN",
24
18
  "xsrfHeaderName": "X-XSRF-TOKEN",
@@ -48,14 +42,11 @@ createRoot(document.getElementById('root')!).render(
48
42
  <button onClick={() => createMessageVerifyModal({
49
43
  data,
50
44
  config,
51
- response: {
52
- config
53
- },
54
45
  lang: 'en',
55
46
  http: axios,
56
- myReject: () => {
47
+ apiReject: () => {
57
48
  },
58
- myResolve: () => {
49
+ apiResolve: () => {
59
50
  }
60
51
  })}>
61
52
  Show verify Modal
package/src/utils/type.ts CHANGED
@@ -20,9 +20,8 @@ export type ModalConfig = {
20
20
  }
21
21
  };
22
22
  api?: string;
23
- response: any;
24
- myReject: any;
25
- myResolve: any;
23
+ apiReject: any;
24
+ apiResolve: any;
26
25
  }
27
26
 
28
27
  export type LoginModalConfig = {
@@ -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', config, myResolve, myReject } = props || {};
15
+ const { data, http, lang, api='/admin/sms/send', config, apiResolve, apiReject } = props || {};
16
16
  const dataObj = JSON.parse(data || '{}');
17
17
  const { mobile, verifyCodeKey } = dataObj || {};
18
18
 
@@ -80,34 +80,24 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
80
80
  <Input.OTP
81
81
  length={6}
82
82
  value={otp}
83
- onChange={async (val) => {
83
+ onChange={(val) => {
84
84
  setOtp(val);
85
85
  if (val.length === 6) {
86
- // try {
87
- http({
88
- ...config,
89
- headers: {
90
- ...http.defaults.headers.common,
91
- 'sms-code': val,
92
- 'sms-code-key': verifyCodeKey,
93
- 'Content-Type': config.headers['Content-Type'],
94
- }
95
- }).then(res => {
96
- setVisible(false);
97
- myResolve(res);
98
- // return res;
99
- }).catch(err => {
100
- myReject(err);
101
- });
102
- // console.log('组件打印res', res);
103
- // if(!res) {
104
- // message.error('验证失败');
105
- // } else {
106
- // message.success('验证成功');
107
- // }
108
- // } catch (error: any) {
109
- // message.error(error?.message || t('sendFailed', lang));
110
- // }
86
+ http({
87
+ ...config,
88
+ headers: {
89
+ ...http.defaults.headers.common,
90
+ 'sms-code': val,
91
+ 'sms-code-key': verifyCodeKey,
92
+ 'Content-Type': config.headers['Content-Type'],
93
+ }
94
+ }).then(res => {
95
+ apiResolve(res);
96
+ }).catch(err => {
97
+ apiReject(err);
98
+ }).finally(() => {
99
+ setVisible(false);
100
+ });
111
101
  }
112
102
  }} />
113
103
  <Button