Files
mixtape/zero.Backoffice.UI/app/core/router/routerConfig.ts
T
2022-01-13 15:04:00 +01:00

34 lines
993 B
TypeScript

import { Zero } from '../types/zero';
import { createWebHistory, Router, RouterOptions } from 'vue-router';
import titleGuard from './titleGuard';
import formDirtyGuard from './formDirtyGuard';
export function getRouterConfig(basePath: string, zero: Zero): RouterOptions
{
let options = {
history: createWebHistory(basePath),
linkActiveClass: 'is-active',
linkExactActiveClass: 'is-active-exact',
scrollBehavior(to, from, savedPosition)
{
return savedPosition ? savedPosition : { x: 0, y: 0 };
},
routes: []
} as RouterOptions;
options.routes.push({ name: 'dashboard', path: '/', redirect: '/pages' }); // component: () => import('../../dashboard.vue') });
options.routes.push({ name: '404', path: '/:pathMatch(.*)', component: () => import('../../notfound.vue') });
return options;
}
export function appendRouterGuards(router: Router): Router
{
//router.beforeEach(formDirtyGuard);
//router.beforeEach(titleGuard);
return router;
}