(no commit message provided)
Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
@ -52,13 +52,15 @@ service.interceptors.response.use(
|
|||||||
let message = error.message || '请求失败'
|
let message = error.message || '请求失败'
|
||||||
|
|
||||||
// 处理 HTTP 状态码错误
|
// 处理 HTTP 状态码错误
|
||||||
|
const isLoginEndpoint = error.config && error.config.url.includes('/login')
|
||||||
|
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
const status = error.response.status
|
const status = error.response.status
|
||||||
const data = error.response.data
|
const data = error.response.data
|
||||||
|
|
||||||
if (status === 401) {
|
if (status === 401) {
|
||||||
// 对于登录接口的401错误,不执行登出重定向,仅提示错误
|
// 对于登录接口的401错误,不执行登出重定向,仅提示错误
|
||||||
if (error.config && !error.config.url.includes('/login')) {
|
if (!isLoginEndpoint) {
|
||||||
message = '登录已过期,请重新登录'
|
message = '登录已过期,请重新登录'
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
window.location.href = '/login'
|
window.location.href = '/login'
|
||||||
@ -76,7 +78,10 @@ service.interceptors.response.use(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 登录接口的错误由调用方单独处理,不再显示全局提示
|
||||||
|
if (!isLoginEndpoint) {
|
||||||
ElMessage.error(message)
|
ElMessage.error(message)
|
||||||
|
}
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user