登录修改

This commit is contained in:
root 2026-04-15 08:48:26 +08:00
parent 4137bc10d7
commit c55f128c22

View File

@ -440,9 +440,12 @@ const handleLogin = async () => {
isLoading.value = true isLoading.value = true
// 访3退200/400/800ms 1.4s // 访
const MAX_HEALTH_ATTEMPTS = 6
const HEALTH_BASE_DELAY_MS = 200
const HEALTH_MAX_DELAY_MS = 1500
let healthOk = false let healthOk = false
for (let attempt = 1; attempt <= 3; attempt++) { for (let attempt = 1; attempt <= MAX_HEALTH_ATTEMPTS; attempt++) {
try { try {
const result = await systemAPI.health() const result = await systemAPI.health()
if (result && result.status === 'healthy') { if (result && result.status === 'healthy') {
@ -450,22 +453,22 @@ const handleLogin = async () => {
break break
} else { } else {
// healthy // healthy
if (attempt === 3) { if (attempt === MAX_HEALTH_ATTEMPTS) {
showError('后台服务异常,请稍后重试!') showError('后台服务异常,请稍后重试!')
isLoading.value = false isLoading.value = false
return return
} }
const delay = 200 * Math.pow(2, attempt - 1) const delay = Math.min(HEALTH_MAX_DELAY_MS, HEALTH_BASE_DELAY_MS * Math.pow(2, attempt - 1))
await new Promise(resolve => setTimeout(resolve, delay)) await new Promise(resolve => setTimeout(resolve, delay))
} }
} catch (error) { } catch (error) {
// //
if (attempt === 3) { if (attempt === MAX_HEALTH_ATTEMPTS) {
showError('网络访问失败,请检查连接后重试!') showError('网络访问失败,请检查连接后重试!')
isLoading.value = false isLoading.value = false
return return
} }
const delay = 200 * Math.pow(2, attempt - 1) const delay = Math.min(HEALTH_MAX_DELAY_MS, HEALTH_BASE_DELAY_MS * Math.pow(2, attempt - 1))
await new Promise(resolve => setTimeout(resolve, delay)) await new Promise(resolve => setTimeout(resolve, delay))
} }
} }