(no commit message provided)

Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
dxc
2026-02-09 10:59:36 +08:00
parent 3f398b74e5
commit f234ca6793
2 changed files with 39 additions and 42 deletions

View File

@ -57,10 +57,13 @@ service.interceptors.response.use(
const data = error.response.data
if (status === 401) {
message = '登录已过期,请重新登录'
// 这里可以触发登出逻辑
localStorage.clear()
window.location.href = '/login'
// 对于登录接口的401错误不执行登出重定向仅提示错误
if (error.config && !error.config.url.includes('/login')) {
message = '登录已过期,请重新登录'
localStorage.clear()
window.location.href = '/login'
}
// 如果是登录接口message会被后面的data.msg覆盖
} else if (status === 403) {
message = '权限不足'
} else if (status === 404) {
@ -78,4 +81,4 @@ service.interceptors.response.use(
}
)
export default service
export default service