diff --git a/frontend/src/api/client.js b/frontend/src/api/client.js index 4eb6e46..c2db49d 100644 --- a/frontend/src/api/client.js +++ b/frontend/src/api/client.js @@ -14,8 +14,10 @@ apiClient.interceptors.response.use((response) => response, (error) => { const { status, data } = error.response; // 未登录 → 跳转登录页 if (status === 401) { - // 避免在登录页循环跳转 - if (window.location.pathname !== '/login') { + // 登录页本身(普通/内部)的 401 是"密码错误",留在原地显示提示 + const path = window.location.pathname; + const isLoginPage = path === '/login' || path === '/internal-login'; + if (!isLoginPage) { window.location.href = '/login'; } return Promise.reject(error); diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index ed83ef3..33a7169 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -19,8 +19,10 @@ apiClient.interceptors.response.use( // 未登录 → 跳转登录页 if (status === 401) { - // 避免在登录页循环跳转 - if (window.location.pathname !== '/login') { + // 登录页本身(普通/内部)的 401 是"密码错误",留在原地显示提示 + const path = window.location.pathname + const isLoginPage = path === '/login' || path === '/internal-login' + if (!isLoginPage) { window.location.href = '/login' } return Promise.reject(error)