1
This commit is contained in:
@@ -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'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user