diff --git a/web/src/utils/request.ts b/web/src/utils/request.ts index 7b8ec6a..dd78e1e 100644 --- a/web/src/utils/request.ts +++ b/web/src/utils/request.ts @@ -113,7 +113,8 @@ export const fetchWithAuth = async ( const response = await fetch(url, fetchOptions) // 统一处理 401 未授权错误 - if (response.status === 401) { + // 注意:如果已经在登录页面,不要跳转,让登录页面自己处理错误提示 + if (response.status === 401 && !window.location.pathname.startsWith('/login')) { console.error('Token已过期或未授权,请重新登录') localStorage.removeItem('token') localStorage.removeItem('user')