fix(frontend): 修复登录失败时通知弹两次的问题

- 在登录页面不再由 http.js 拦截器弹出 401 通知
- 让 LoginPage.vue 自己处理登录错误的显示
- 避免同一错误消息重复弹出
This commit is contained in:
2026-01-21 19:45:43 +08:00
parent 156d3a97b2
commit f46f325518
13 changed files with 34 additions and 31 deletions

View File

@@ -44,9 +44,12 @@ publicApi.interceptors.response.use(
const message = payload?.error || payload?.message || error?.message || '请求失败'
if (status === 401) {
toastErrorOnce('401', message || '登录已过期,请重新登录', 3000)
const pathname = window.location?.pathname || ''
if (!pathname.startsWith('/login')) window.location.href = '/login'
// 登录页面不弹通知,让 LoginPage.vue 自己处理错误显示
if (!pathname.startsWith('/login')) {
toastErrorOnce('401', message || '登录已过期,请重新登录', 3000)
window.location.href = '/login'
}
} else if (status === 403) {
toastErrorOnce('403', message || '无权限', 5000)
} else if (error?.code === 'ECONNABORTED') {