From 41487b9a8ad1353c21dd1ac2bfafcf8d1d4f34e4 Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期五, 28 八月 2026 17:09:47 +0800
Subject: [PATCH] feat: 所有前端 API 请求加超时保护,超时/网络异常优雅提示,不再无限 pending
---
traffic-audit-web/src/views/Login.vue | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/traffic-audit-web/src/views/Login.vue b/traffic-audit-web/src/views/Login.vue
index 2227171..f7dc1a7 100644
--- a/traffic-audit-web/src/views/Login.vue
+++ b/traffic-audit-web/src/views/Login.vue
@@ -44,7 +44,7 @@
}
},
created() {
- axios.get('/api/auth/captcha-config')
+ axios.get('/api/auth/captcha-config', { timeout: 10000 })
.then(res => {
const d = res.data
if (d && d.code === 200) this.captchaRequired = d.data.required !== false
@@ -75,7 +75,7 @@
password: this.form.password,
captchaId: this.captchaId,
captchaClickIds: this.clickIds
- }).then(res => {
+ }, { timeout: 15000 }).then(res => {
this.loggingIn = false
const d = res.data
if (d.code === 200) {
@@ -95,8 +95,9 @@
this.$message.error(d.message || '鐧诲綍澶辫触锛岃閲嶈瘯')
if (this.$refs.captcha) this.$refs.captcha.load()
}
- }).catch(() => {
+ }).catch(e => {
this.loggingIn = false
+ if (e && e.code === 'ECONNABORTED') { this.$message.error('鐧诲綍璇锋眰瓒呮椂锛岃閲嶈瘯'); return }
this.$message.error('缃戠粶閿欒锛岀櫥褰曞け璐�')
})
})
--
Gitblit v1.9.1