提交 d144b90d authored 作者: lhh's avatar lhh

update

上级 f106bfc2
......@@ -7,33 +7,22 @@ const router = createRouter({
})
router.beforeEach(async (to, from, next) => {
const whiteList = ['/401']
const user = useUserStore()
if (!user.isLogin && !whiteList.includes(to.path)) {
try {
await user.getUser()
} catch (e) {
console.error(e)
if (to.path !== '/register') {
const whiteList = ['/401']
const user = useUserStore()
if (!user.isLogin && !whiteList.includes(to.path)) {
try {
await user.getUser()
} catch (e) {
console.error(e)
}
user.isLogin ? next() : next('/401')
return
}
user.isLogin ? next() : next('/401')
return
next()
} else {
next()
}
next()
// if (to.path !== '/register') {
// const user = useUserStore()
// if (!user.isLogin && !whiteList.includes(to.path)) {
// try {
// await user.getUser()
// } catch (e) {
// console.error(e)
// }
// user.isLogin ? next() : next('/401')
// return
// }
// next()
// } else {
// next()
// }
})
export default router
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论