message-verify 1.0.0-beta.17 → 1.0.0-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.
@@ -63,32 +63,30 @@ const CreateMessageVerifyModal = ({ props }) => {
63
63
  return (_jsxs(Modal, { width: 420, visible: visible, onClose: () => {
64
64
  setVisible(false);
65
65
  props.onClose?.();
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: (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) => {
67
67
  setOtp(val);
68
68
  if (val.length === 6) {
69
- http({
70
- ...config,
71
- headers: {
72
- ...http.defaults.headers.common,
73
- 'sms-code': val,
74
- 'sms-code-key': verifyCodeKey,
75
- 'Content-Type': config.headers['Content-Type'],
69
+ try {
70
+ const res = await http({
71
+ ...config,
72
+ headers: {
73
+ ...http.defaults.headers.common,
74
+ 'sms-code': val,
75
+ 'sms-code-key': verifyCodeKey,
76
+ 'Content-Type': config.headers['Content-Type'],
77
+ }
78
+ });
79
+ // 健壮性判断
80
+ if (!res || !res.data || !res.data.status) {
81
+ console.log('response结构异常', res);
82
+ return;
76
83
  }
77
- });
78
- http.interceptors.response.use((response) => {
79
- // 先做健壮性判断
80
- if (!response || !response.data || !response.data.status) {
81
- console.log('response结构异常', response);
82
- return response;
83
- }
84
- const { code, detail } = response.data.status;
85
- const responseType = response.config?.responseType;
86
- console.log('打印', detail, code, responseType);
87
- return response;
88
- }, (error) => {
89
- console.log('打印', error);
90
- return Promise.reject(error);
91
- });
84
+ const { code, detail } = res.data.status;
85
+ console.log('打印', detail, code);
86
+ }
87
+ catch (error) {
88
+ console.log('请求异常', error);
89
+ }
92
90
  }
93
91
  } }), _jsx(Button, { disabled: countdown > 0 || !captchCode, onClick: handleResend, style: { padding: '8px' }, children: countdown > 0 ? t('countDownSecound', lang, { countdown }) : t('reSend', lang) })] }), countdown > 0 ? null :
94
92
  _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.0-beta.17",
3
+ "version": "1.0.0-beta.18",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
@@ -78,35 +78,29 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
78
78
  <Input.OTP
79
79
  length={6}
80
80
  value={otp}
81
- onChange={(val) => {
81
+ onChange={async (val) => {
82
82
  setOtp(val);
83
83
  if (val.length === 6) {
84
- http({
85
- ...config,
86
- headers: {
87
- ...http.defaults.headers.common,
88
- 'sms-code': val,
89
- 'sms-code-key': verifyCodeKey,
90
- 'Content-Type': config.headers['Content-Type'],
91
- }
92
- });
93
- (http as any).interceptors.response.use(
94
- (response: any) => {
95
- // 先做健壮性判断
96
- if (!response || !response.data || !response.data.status) {
97
- console.log('response结构异常', response);
98
- return response;
84
+ try {
85
+ const res = await http({
86
+ ...config,
87
+ headers: {
88
+ ...http.defaults.headers.common,
89
+ 'sms-code': val,
90
+ 'sms-code-key': verifyCodeKey,
91
+ 'Content-Type': config.headers['Content-Type'],
99
92
  }
100
- const { code, detail } = response.data.status;
101
- const responseType = response.config?.responseType;
102
- console.log('打印', detail, code, responseType);
103
- return response;
104
- },
105
- (error: unknown) => {
106
- console.log('打印', error);
107
- return Promise.reject(error);
108
- },
109
- );
93
+ }) as any;
94
+ // 健壮性判断
95
+ if (!res || !res.data || !res.data.status) {
96
+ console.log('response结构异常', res);
97
+ return;
98
+ }
99
+ const { code, detail } = res.data.status;
100
+ console.log('打印', detail, code);
101
+ } catch (error) {
102
+ console.log('请求异常', error);
103
+ }
110
104
  }
111
105
  }} />
112
106
  <Button