import Vue from "vue"; import VueRouter, { RouteConfig } from "vue-router"; /* Layout */ import damsRouter from './modules/dams' /* Router modules */ Vue.use(VueRouter); /** ConstantRoutes a base page that does not have permission requirements all roles can be accessed */ export const constantRoutes: RouteConfig[] = [ { path: "/", redirect: "/dams", meta: { hidden: true }, }, { path: "/dams", component: () => import(/* webpackChunkName: "login" */ "../views/dams/index.vue"), meta: { hidden: true }, }, ]; /** * asyncRoutes * the routes that need to be dynamically loaded based on user roles */ export const asyncRoutes = () => { const system = { path: '/system', label: true, meta: { title: 'system' } } const routes: RouteConfig[] = [ damsRouter, ] return routes; }; const createRouter = () => new VueRouter({ // mode: 'history', // Disabled due to Github Pages doesn't support this, enable this if you need. scrollBehavior: (_to, _from, savedPosition) => { if (savedPosition) { return savedPosition; } else { return { x: 0, y: 0 }; } }, base: process.env.BASE_URL, routes: constantRoutes, }); const router = createRouter(); // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465 export function resetRouter() { const newRouter = createRouter(); (router as any).matcher = (newRouter as any).matcher; // reset router } export default router;