|
@@ -15,7 +15,7 @@ const { loadingBar } = useDiscreteApi()
|
|
|
const configureStore = useConfigureStore(createPinia())
|
|
const configureStore = useConfigureStore(createPinia())
|
|
|
|
|
|
|
|
export function setupRouterGuard(router: Router) {
|
|
export function setupRouterGuard(router: Router) {
|
|
|
- router.beforeEach(async (to, from, next) => {
|
|
|
|
|
|
|
+ router.beforeEach(async (to, from) => {
|
|
|
console.log({ to, from })
|
|
console.log({ to, from })
|
|
|
console.log(to.name)
|
|
console.log(to.name)
|
|
|
console.log(to.path)
|
|
console.log(to.path)
|
|
@@ -43,21 +43,19 @@ export function setupRouterGuard(router: Router) {
|
|
|
name: payload?.name ?? '',
|
|
name: payload?.name ?? '',
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- next(from.fullPath)
|
|
|
|
|
|
|
+ return from.fullPath
|
|
|
} else {
|
|
} else {
|
|
|
// 🚨 登录参数错误时跳转到 errorPage
|
|
// 🚨 登录参数错误时跳转到 errorPage
|
|
|
- next({ name: 'errorPage' })
|
|
|
|
|
|
|
+ return { name: 'errorPage' }
|
|
|
}
|
|
}
|
|
|
- return
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (to.name === 'signin') {
|
|
if (to.name === 'signin') {
|
|
|
if (!userStore.token) {
|
|
if (!userStore.token) {
|
|
|
- next()
|
|
|
|
|
|
|
+ return
|
|
|
} else {
|
|
} else {
|
|
|
- next(from.fullPath)
|
|
|
|
|
|
|
+ return from.fullPath
|
|
|
}
|
|
}
|
|
|
- return
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!userStore.token) {
|
|
if (!userStore.token) {
|
|
@@ -66,7 +64,6 @@ export function setupRouterGuard(router: Router) {
|
|
|
} else {
|
|
} else {
|
|
|
userStore.cleanup(to.fullPath)
|
|
userStore.cleanup(to.fullPath)
|
|
|
}
|
|
}
|
|
|
- next()
|
|
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -82,22 +79,16 @@ export function setupRouterGuard(router: Router) {
|
|
|
children: userStore.routeList,
|
|
children: userStore.routeList,
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- next(to.fullPath)
|
|
|
|
|
|
|
+ return to.fullPath
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('Error resolving user menu or adding route:', error)
|
|
console.error('Error resolving user menu or adding route:', error)
|
|
|
userStore.cleanup()
|
|
userStore.cleanup()
|
|
|
- next()
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- return
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- next()
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- router.beforeResolve((_, __, next) => {
|
|
|
|
|
- next()
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // next已弃用
|
|
|
|
|
+ router.beforeResolve((_, __) => {})
|
|
|
|
|
|
|
|
router.afterEach(() => {
|
|
router.afterEach(() => {
|
|
|
configureStore.setNavigating(false)
|
|
configureStore.setNavigating(false)
|