Pre Merge pull request !840 from 熊猫大侠/dev-tmp

pull/840/MERGE
熊猫大侠 2025-12-26 13:08:46 +00:00 committed by Gitee
commit 156520c0cd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 8 additions and 1 deletions

View File

@ -161,6 +161,8 @@ service.interceptors.response.use(
}
// 2. 进行刷新访问令牌
try {
// 刷新令牌时,需要将 isRelogin.show 设置为 false解决在后台失效token前端缓存token,登录页卡死的问题
isRelogin.show = false
const refreshTokenRes = await refreshToken()
// 2.1 刷新成功,则回放队列的请求 + 当前请求
setToken((await refreshTokenRes).data.data)
@ -246,7 +248,12 @@ const handleAuthorized = () => {
if (!isRelogin.show) {
// 如果已经到登录页面则不进行弹窗提示
if (window.location.href.includes('login')) {
return
// 后台refreshtoken失效前台缓存token存在直接访问Login页面会卡死。
// 清除掉token重新走路由守卫确保本地即使缓存了token也是能正常加载登录页前提是要确保isRelogin.show为false
// https://wx.zsxq.com/group/88858522214142/topic/45811881251414188
removeToken()
window.location.href = window.location.href
// return
}
isRelogin.show = true
ElMessageBox.confirm(t('sys.api.timeoutMessage'), t('common.confirmTitle'), {