路由注释代码取消
This commit is contained in:
@@ -39,43 +39,43 @@ const router = createRouter({
|
|||||||
})
|
})
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
// const token = cache.local.get('token')
|
const token = cache.local.get('token')
|
||||||
// if (token) {
|
if (token) {
|
||||||
// if (whiteList.indexOf(to.path) !== -1) {
|
if (whiteList.indexOf(to.path) !== -1) {
|
||||||
// next()
|
|
||||||
// } else {
|
|
||||||
// if (useUserStore().roles.length === 0) {
|
|
||||||
// // 判断当前用户是否已拉取完user_info信息
|
|
||||||
// useUserStore().getInfo().then(() => {
|
|
||||||
// usePermissionStore().generateRoutes().then(accessRoutes => {
|
|
||||||
// accessRoutes.forEach(route => {
|
|
||||||
// router.addRoute(route) // 动态添加可访问路由表
|
|
||||||
// })
|
|
||||||
|
|
||||||
// next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
|
||||||
// })
|
|
||||||
// }).catch(err => {
|
|
||||||
// // 登出接口防抖操作
|
|
||||||
// debounce(() => {
|
|
||||||
// useUserStore().logout().then(() => {
|
|
||||||
// ElMessage.error(err)
|
|
||||||
// next({ path: '/login' })
|
|
||||||
// })
|
|
||||||
// }, 1000)()
|
|
||||||
// })
|
|
||||||
// } else {
|
|
||||||
// next()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// // 没有token
|
|
||||||
// if (whiteList.indexOf(to.path) !== -1) {
|
|
||||||
// // 在免登录白名单,直接进入
|
|
||||||
next()
|
next()
|
||||||
// } else {
|
} else {
|
||||||
// // next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
if (useUserStore().roles.length === 0) {
|
||||||
// next('/login') // 否则全部重定向到登录页
|
// 判断当前用户是否已拉取完user_info信息
|
||||||
// }
|
useUserStore().getInfo().then(() => {
|
||||||
// }
|
usePermissionStore().generateRoutes().then(accessRoutes => {
|
||||||
|
accessRoutes.forEach(route => {
|
||||||
|
router.addRoute(route) // 动态添加可访问路由表
|
||||||
|
})
|
||||||
|
|
||||||
|
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
||||||
|
})
|
||||||
|
}).catch(err => {
|
||||||
|
// 登出接口防抖操作
|
||||||
|
debounce(() => {
|
||||||
|
useUserStore().logout().then(() => {
|
||||||
|
ElMessage.error(err)
|
||||||
|
next({ path: '/login' })
|
||||||
|
})
|
||||||
|
}, 1000)()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 没有token
|
||||||
|
if (whiteList.indexOf(to.path) !== -1) {
|
||||||
|
// 在免登录白名单,直接进入
|
||||||
|
next()
|
||||||
|
} else {
|
||||||
|
// next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
||||||
|
next('/login') // 否则全部重定向到登录页
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
export default router
|
export default router
|
||||||
|
|||||||
Reference in New Issue
Block a user