完善登录与状态回显处理
This commit is contained in:
@@ -76,7 +76,7 @@ export default function Captcha(props: CaptchaProps) {
|
||||
取消
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => handleVerifyCaptcha()}
|
||||
onClick={handleVerifyCaptcha}
|
||||
>
|
||||
确认
|
||||
</Button>
|
||||
|
||||
@@ -79,26 +79,32 @@ export default function LoginPage(props: LoginPageProps) {
|
||||
}
|
||||
|
||||
// 发送验证码
|
||||
const resp = await verify({
|
||||
phone: username,
|
||||
captcha: captchaCode,
|
||||
})
|
||||
let resp: ApiResponse
|
||||
try {
|
||||
resp = await verify({
|
||||
phone: username,
|
||||
captcha: captchaCode,
|
||||
})
|
||||
}
|
||||
catch (e) {
|
||||
toast.error(`请求失败:${e}`)
|
||||
return false
|
||||
}
|
||||
|
||||
// 处理验证码发送结果
|
||||
let waiting = 60
|
||||
if (!resp.success) {
|
||||
if (resp.status == 429) {
|
||||
setShowCaptcha(false)
|
||||
waiting = parseInt(resp.message)
|
||||
console.log(resp.message)
|
||||
toast.error('发送频率过快', {
|
||||
description: '请稍后再试',
|
||||
})
|
||||
}
|
||||
else {
|
||||
if (resp.status != 429) {
|
||||
toast.error(resp.message)
|
||||
return true
|
||||
}
|
||||
|
||||
setShowCaptcha(false)
|
||||
waiting = parseInt(resp.message)
|
||||
console.log(resp.message)
|
||||
toast.error('发送频率过快', {
|
||||
description: '请稍后再试',
|
||||
})
|
||||
}
|
||||
else {
|
||||
setShowCaptcha(false)
|
||||
@@ -125,10 +131,6 @@ export default function LoginPage(props: LoginPageProps) {
|
||||
return false
|
||||
}, [username])
|
||||
|
||||
const setWaiting = (resp: ApiResponse<undefined>) => {
|
||||
|
||||
}
|
||||
|
||||
// 处理表单提交
|
||||
const onSubmit = async (values: FormValues) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user