diff --git a/src/utils/http.js b/src/utils/http.js index e6d246eb..8eda3715 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -53,9 +53,7 @@ http.interceptors.response.use( if (error.response.status === 401) { // 清除token并重定向到登录页 localStorage.removeItem('jwt_token'); - // 这里需要访问router,但http.js是纯工具文件,不应直接依赖Vue Router实例 - // 可以在main.js的全局错误处理或组件中处理401错误 - // 例如:window.location.href = '/login'; + window.location.href = '/login'; } } else if (error.request) { // 请求发出但没有收到响应