This commit is contained in:
amb
2026-09-02 17:00:51 +08:00
parent b4dfc5e711
commit 6a2de55332
2 changed files with 8 additions and 4 deletions
+4 -2
View File
@@ -14,8 +14,10 @@ apiClient.interceptors.response.use((response) => response, (error) => {
const { status, data } = error.response; const { status, data } = error.response;
// 未登录 → 跳转登录页 // 未登录 → 跳转登录页
if (status === 401) { if (status === 401) {
// 避免在登录页循环跳转 // 登录页本身(普通/内部)的 401 是"密码错误",留在原地显示提示
if (window.location.pathname !== '/login') { const path = window.location.pathname;
const isLoginPage = path === '/login' || path === '/internal-login';
if (!isLoginPage) {
window.location.href = '/login'; window.location.href = '/login';
} }
return Promise.reject(error); return Promise.reject(error);
+4 -2
View File
@@ -19,8 +19,10 @@ apiClient.interceptors.response.use(
// 未登录 → 跳转登录页 // 未登录 → 跳转登录页
if (status === 401) { if (status === 401) {
// 避免在登录页循环跳转 // 登录页本身(普通/内部)的 401 是"密码错误",留在原地显示提示
if (window.location.pathname !== '/login') { const path = window.location.pathname
const isLoginPage = path === '/login' || path === '/internal-login'
if (!isLoginPage) {
window.location.href = '/login' window.location.href = '/login'
} }
return Promise.reject(error) return Promise.reject(error)