fix: prevent full page reload on login failure (401 on /auth/login)

The axios 401 interceptor was redirecting to /login for every 401 response,
including failed login attempts. Now it skips the redirect when the request
is to /auth/login, letting the LoginView handle the error gracefully.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
祀梦
2026-05-17 16:01:04 +08:00
parent 9d4d869d57
commit 0bca9e6654

View File

@@ -28,6 +28,9 @@ instance.interceptors.response.use(
message = data?.detail || '请求参数有误,请检查一下~'
break
case 401:
if (error.config?.url?.includes('/auth/login')) {
break
}
message = '登录状态已失效~'
window.location.href = '/login'
return Promise.reject(error)