import Vue from "vue"; import VueRouter, { Route, RouteConfig } from "vue-router"; import { Code } from "@/constants/enum/general/code.enum"; import mainRoutes from "@/router/main.routing"; import customerRoutes from "@/router/customer.mgt.routing"; import marketingRoutes from "@/router/marketing.mgt.routing"; import workbenchRoutes from "@/router/workbench.routing"; Vue.use(VueRouter); const routes: Array = [ { path: "/", redirect: `/login`, meta: { keepAlive: true, requiresAuth: true }, }, { path: "/login", component: () => import(/* webpackChunkName: "login" */ "@/views/authentication/LoginView.vue"), meta: { keepAlive: true, requiresAuth: true }, }, ...mainRoutes, ...customerRoutes, ...marketingRoutes, ...workbenchRoutes, ]; const router = new VueRouter({ mode: "hash", base: process.env.VUE_APP_BASEURL, routes, }); router.beforeEach((to: Route, from: Route, next: () => void) => { // router.app.$routeTopologyService.checkAndInit(router); // if (to.matched.some((record: any) => record.meta && record.meta.requiresAuth)) { // router.app.$oauthService // .checkAndLogin() // .then((res: RestfulResponse) => { // if (res.code === Code.SUCCESS.code) { // router.app.$globalStateService.isLogin = true; // } // return Promise.resolve(res); // }) // .then((res: any) => { // if (res.code === Code.SUCCESS.code) { // next(); // } // }); // } else { // next(); // } next(); }); export default router;