12345678910111213141516171819202122232425262728293031323334353637 |
- import { fn_logout } from '@/utils'
- const paths = ['/login']
- export function createRouterGuards(router, systemStore) {
- const routes = router.getRoutes()
-
- router.beforeEach(async (to, from, next) => {
-
- if (paths.includes(to.path)) {
-
- fn_logout()
- return next()
- }
-
- const menus = systemStore.getMenus
- if(menus.length == 0) return next('/login')
- if (to.matched.length === 0) {
- return next('/errors')
- }
-
- next()
- })
- router.afterEach((to, _, next) => {
-
-
-
- })
-
- router.onError(error => {
- console.log(error, '路由错误')
- })
- }
|