/** * Vue Router * * @library * * https://router.vuejs.org/en/ */ // Lib imports import Vue from 'vue' import Router from 'vue-router' import Meta from 'vue-meta' // Routes import paths from './paths' function route (options) { let path = options.path; let view = options.view; let name = options.name; let meta = (options.meta) ? options.meta : ''; return { name: name || view, path, meta, component: (resovle) => import( `@show/views/${view}.vue` ).then(resovle) } } Vue.use(Router) console.log(paths); // Create a new router const router = new Router({ mode: 'history', routes: paths.map(path => route(path)).concat([ { path: '*', redirect: '/' } ]), }) Vue.use(Meta) // import {$hasRole} from '@/services/acl/role'; router.beforeEach((to, from, next) => { const isPublic = to.matched.some(record => record.meta.public); const onlyWhenLoggedOut = to.matched.some(record => record.meta.onlyWhenLoggedOut); const roles = (to.meta && to.meta.roles) ? to.meta.roles : null; // Do not allow user to visit Pages then not access roles next(); }); export default router