ai编写项目设计书,解决重复跳转login的bug

This commit is contained in:
2026-09-28 14:13:36 +08:00
parent c3a6d2bc5b
commit afedec626f
3 changed files with 202 additions and 5 deletions
+1 -3
View File
@@ -1,6 +1,5 @@
import axios from 'axios';
import store from '../store';
import router from '../router';
// 配置请求
const request = axios.create({
@@ -30,10 +29,9 @@ request.interceptors.response.use(
},
(error) => {
if (error.response && error.response.status === 401) {
// 如果返回401,说明token过期或无效,清除token并跳转到登录页
// 如果返回401,说明token过期或无效,清除token
store.commit('SET_TOKEN', '');
store.commit('SET_USERNAME', '');
router.push('/login');
}
return Promise.reject(error);
}