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 -2
View File
@@ -316,7 +316,6 @@ export default {
closeWebSocket();
this.$store.commit("SET_TOKEN", "");
this.$store.commit("SET_USERNAME", "");
this.$router.push("/login");
},
// 获取当前登录用户信息
@@ -329,7 +328,6 @@ export default {
.catch((error) => {
console.error(error);
this.$message.error("获取用户信息失败,请重新登录");
this.$router.push("/login");
});
},
@@ -556,6 +554,7 @@ export default {
sendWebSocketMessage({
type: "ack",
messageId: message.messageId,
senderName: this.currentUser.username
});
this.$nextTick(() => {
this.scrollToBottom();
+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);
}