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