message-verify 1.0.1-beta.22 → 1.0.1-beta.24
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/verify-modal.js +34 -12
- package/package.json +1 -1
- package/src/verify-modal.tsx +34 -12
package/dist/verify-modal.js
CHANGED
@@ -69,20 +69,42 @@ const CreateMessageVerifyModal = ({ props }) => {
|
|
69
69
|
setOtp(val);
|
70
70
|
if (val.length === 6) {
|
71
71
|
try {
|
72
|
-
const res = await
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
72
|
+
const res = await Promise.race([
|
73
|
+
new Promise((resolve, reject) => {
|
74
|
+
setTimeout(() => {
|
75
|
+
reject(new Error('Timeout'));
|
76
|
+
}, 1000);
|
77
|
+
}),
|
78
|
+
new Promise((resolve, reject) => {
|
79
|
+
http({
|
80
|
+
...config,
|
81
|
+
headers: {
|
82
|
+
...http.defaults.headers.common,
|
83
|
+
'sms-code': val,
|
84
|
+
'sms-code-key': verifyCodeKey,
|
85
|
+
'Content-Type': config.headers['Content-Type'],
|
86
|
+
}
|
87
|
+
}).then(res => {
|
88
|
+
resolve(res);
|
89
|
+
}).catch(err => {
|
90
|
+
reject(err);
|
91
|
+
});
|
92
|
+
})
|
93
|
+
]);
|
94
|
+
// const res = await http({
|
95
|
+
// ...config,
|
96
|
+
// headers: {
|
97
|
+
// ...http.defaults.headers.common,
|
98
|
+
// 'sms-code': val,
|
99
|
+
// 'sms-code-key': verifyCodeKey,
|
100
|
+
// 'Content-Type': config.headers['Content-Type'],
|
101
|
+
// }
|
102
|
+
// })
|
81
103
|
console.log('resresresresres');
|
82
104
|
console.log('res', res);
|
83
105
|
if (!res) {
|
84
106
|
message.error('验证失败');
|
85
|
-
apiReject();
|
107
|
+
// apiReject();
|
86
108
|
}
|
87
109
|
else {
|
88
110
|
apiResolve(res);
|
@@ -90,9 +112,9 @@ const CreateMessageVerifyModal = ({ props }) => {
|
|
90
112
|
setVisible(false);
|
91
113
|
}
|
92
114
|
catch (error) {
|
93
|
-
console.
|
115
|
+
console.warn('catch', error);
|
94
116
|
message.error('验证失败');
|
95
|
-
apiReject(error);
|
117
|
+
// apiReject(error);
|
96
118
|
setVisible(false);
|
97
119
|
}
|
98
120
|
}
|
package/package.json
CHANGED
package/src/verify-modal.tsx
CHANGED
@@ -85,28 +85,50 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
85
85
|
setOtp(val);
|
86
86
|
if (val.length === 6) {
|
87
87
|
try {
|
88
|
-
const res = await
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
88
|
+
const res = await Promise.race([
|
89
|
+
new Promise((resolve, reject) => {
|
90
|
+
setTimeout(() => {
|
91
|
+
reject(new Error('Timeout'));
|
92
|
+
}, 1000);
|
93
|
+
}),
|
94
|
+
new Promise((resolve, reject) => {
|
95
|
+
http({
|
96
|
+
...config,
|
97
|
+
headers: {
|
98
|
+
...http.defaults.headers.common,
|
99
|
+
'sms-code': val,
|
100
|
+
'sms-code-key': verifyCodeKey,
|
101
|
+
'Content-Type': config.headers['Content-Type'],
|
102
|
+
}
|
103
|
+
}).then(res => {
|
104
|
+
resolve(res);
|
105
|
+
}).catch(err => {
|
106
|
+
reject(err);
|
107
|
+
})
|
108
|
+
})
|
109
|
+
])
|
110
|
+
// const res = await http({
|
111
|
+
// ...config,
|
112
|
+
// headers: {
|
113
|
+
// ...http.defaults.headers.common,
|
114
|
+
// 'sms-code': val,
|
115
|
+
// 'sms-code-key': verifyCodeKey,
|
116
|
+
// 'Content-Type': config.headers['Content-Type'],
|
117
|
+
// }
|
118
|
+
// })
|
97
119
|
console.log('resresresresres')
|
98
120
|
console.log('res', res);
|
99
121
|
if (!res) {
|
100
122
|
message.error('验证失败');
|
101
|
-
apiReject();
|
123
|
+
// apiReject();
|
102
124
|
} else {
|
103
125
|
apiResolve(res);
|
104
126
|
}
|
105
127
|
setVisible(false);
|
106
128
|
} catch (error) {
|
107
|
-
console.
|
129
|
+
console.warn('catch', error);
|
108
130
|
message.error('验证失败');
|
109
|
-
apiReject(error);
|
131
|
+
// apiReject(error);
|
110
132
|
setVisible(false);
|
111
133
|
}
|
112
134
|
}
|