import router from './index'; import util from '@/libs/util'; import Setting from '@/setting'; import generateRoutes from '@/libs/route/generateRoutes'; import bus from '@/libs/bus'; router.beforeEach((to, from, next) => { document.title = to.meta.title ? `${to.meta.title} | ${Setting.titleSuffix}` : Setting.titleSuffix; const role = util.session.get(Setting.usernameKey); if (!role && to.path !== '/login') { next('/login') // if(to.fullPath == '/'){ // next('/login') // }else{ // next({ // path: '/login', // query: {redirect: to.fullPath} // }) // } } else if(role && to.path == '/login') { next('/index') } else { if(to.meta.sidebar){ bus.$emit('showMenu', true) }else{ bus.$emit('showMenu', false) } next(); } }); // Setting.dynamicRoute && generateRoutes()