fix: 修复未登录跳转 /profile 导致的导航拦截刷新问题;修复 401 误重定向至不存在路径 /login 的 Bug
This commit is contained in:
parent
42d197dd2d
commit
eeeff9942e
|
|
@ -23,7 +23,7 @@ http.interceptors.response.use(
|
||||||
userStore.reset()
|
userStore.reset()
|
||||||
// _noRedirect 标记:静默验证时不跳转(避免注册/登录页被重定向)
|
// _noRedirect 标记:静默验证时不跳转(避免注册/登录页被重定向)
|
||||||
if (!err.config?._noRedirect) {
|
if (!err.config?._noRedirect) {
|
||||||
router.push('/login')
|
router.push({ path: '/', query: { showLogin: 1 } })
|
||||||
}
|
}
|
||||||
return Promise.reject(err)
|
return Promise.reject(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,10 @@ async function handleCommand(cmd) {
|
||||||
}
|
}
|
||||||
router.push('/works')
|
router.push('/works')
|
||||||
} else if (cmd === 'profile') {
|
} else if (cmd === 'profile') {
|
||||||
|
if (!isLoggedIn.value) {
|
||||||
|
loginDialogRef.value?.open()
|
||||||
|
return
|
||||||
|
}
|
||||||
router.push('/profile')
|
router.push('/profile')
|
||||||
} else if (cmd === 'vip') {
|
} else if (cmd === 'vip') {
|
||||||
showPayment?.()
|
showPayment?.()
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,11 @@ router.beforeEach(async (to, from, next) => {
|
||||||
router.onError((error) => {
|
router.onError((error) => {
|
||||||
const pattern = /Failed to fetch dynamically imported module|Importing a module script failed/i
|
const pattern = /Failed to fetch dynamically imported module|Importing a module script failed/i
|
||||||
if (pattern.test(error?.message || '')) {
|
if (pattern.test(error?.message || '')) {
|
||||||
window.location.reload()
|
const isReloaded = sessionStorage.getItem('chunk_reload_flag')
|
||||||
|
if (!isReloaded) {
|
||||||
|
sessionStorage.setItem('chunk_reload_flag', 'true')
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue