完善登录与状态回显处理

This commit is contained in:
2025-03-28 15:00:46 +08:00
parent e16ef8e509
commit a16faadaab
17 changed files with 463 additions and 285 deletions

View File

@@ -76,7 +76,7 @@ export default function Captcha(props: CaptchaProps) {
</Button>
<Button
onClick={() => handleVerifyCaptcha()}
onClick={handleVerifyCaptcha}
>
</Button>

View File

@@ -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 {