This commit is contained in:
2026-08-05 11:32:05 +08:00
parent e54c3fff84
commit 13672fb217
10 changed files with 111 additions and 28 deletions
+5
View File
@@ -1,5 +1,6 @@
import axios from 'axios'
import { ElMessage } from 'element-plus'
import { useAuthStore } from '../stores/auth.js'
const request = axios.create({
timeout: 300000
@@ -14,6 +15,10 @@ request.interceptors.request.use(config => {
})
function redirectLogin() {
// 同时清空 Pinia store,否则路由守卫仍视为已登录,会拦回首页形成死循环
try {
useAuthStore().logout()
} catch { /* store 未初始化时忽略 */ }
localStorage.removeItem('token')
window.location.href = '/#/login'
}