fix:重定向白屏需强刷bug

This commit is contained in:
guoyue 2022-09-29 11:02:23 +08:00
parent a7d7431c75
commit 3f4e27177c
1 changed files with 15 additions and 6 deletions

View File

@ -32,12 +32,13 @@ const handleCode = (code, msg, res) => {
// debugger
switch (code) {
case 401:
store.dispatch('user/resetAll').catch(() => {})
debugger
store.dispatch('user/resetAll').catch(() => { })
break
case 403:
router.push({
path: '/401'
}).catch(() => {})
}).catch(() => { })
break
case 500:
message.error(msg || '接口异常')
@ -111,11 +112,19 @@ instance.interceptors.response.use(
setAccessToken(response.headers.token)
}
if (response.headers.redirect) {
const _old_href = window.location.href.split('#')[0];
const _new_href = response.headers.redirect.split('#')[0];
window.location.replace(response.headers.redirect)
// 西-
// if(!whoShow.itShowXiHaiAn) {
// location.reload()
// }
// url
if (_old_href === _new_href) {
location.reload()
}
// location.reload()
// 西-
// if(!whoShow.itShowXiHaiAn) {
// location.reload()
// }
return response
}
if (response.headers.redirect === '/#/login') {