fix: 修复登录页面401错误处理问题
根本原因: - request拦截器在收到401错误时立即重定向到登录页 - 这会中断Login.vue的错误处理逻辑 - 导致ElMessage.error()无法执行,错误消息toast无法显示 修复方案: - 在登录页面时不执行重定向 - 允许Login.vue正常处理错误并显示toast消息 - 改进测试等待策略,确保toast消息出现
This commit is contained in:
@@ -47,7 +47,9 @@ request.interceptors.response.use(
|
||||
(error) => {
|
||||
if (error.response?.status === 401) {
|
||||
localStorage.removeItem('token')
|
||||
window.location.href = '/login'
|
||||
if (!window.location.pathname.includes('/login')) {
|
||||
window.location.href = '/login'
|
||||
}
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user