123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import Vue from "vue";
- import VueRouter from "vue-router";
- import Home from "../views/home/Index.vue";
- Vue.use(VueRouter);
- const createRouter = () =>
- new VueRouter({
- mode: "history",
- base: process.env.BASE_URL,
- scrollBehavior: () => ({ y: 0 }),
- routes: [
- {
- path: "/",
- redirect: "/login",
- },
- {
- path: "/home",
- redirect: "/home/cockpitManage",
- name: "home",
- component: Home,
- children: [
- // 驾驶舱
- {
- id: 1,
- path: "cockpitManage",
- name: "驾驶舱",
- iconName: "gps",
- component: () =>
- import(
- // /*webpackChunkName:'home-cockpitManage'*/ "../views/admin/cockpitManage/Index.vue"
- /*webpackChunkName:'home-cockpitManage'*/ "../views/admin/cockpitManage/HD.vue"
- ),
- },
- {
- // 电子地图
- id: 11,
- path: "/home/cockpitManage/electronic-map",
- name: "电子地图",
- component: () =>
- import(
- /*webpackChunkName:'home-cockpitManage'*/ "../views/admin/cockpitManage/electronicMap.vue"
- ),
- },
- // {
- // id: 11,
- // path: "/home/performance/customAnalysis",
- // name: "自定义分析",
- // component: () =>
- // import(
- // /*webpackChunkName:'home-cockpitManage'*/ "../views/performance/customAnalysis.vue"
- // ),
- // },
- // {
- // id: 11,
- // path: "/home/performance/luckySheet",
- // name: "自定义分析表格编辑",
- // component: () =>
- // import(
- // /*webpackChunkName:'home-cockpitManage'*/ "../views/performance/components/custonAsCom/luckySheet.vue"
- // ),
- // },
- ],
- },
- {
- path: "/login",
- name: "login",
- component: () => import("../views/login/Index.vue"),
- },
- {
- path: "/transition",
- name: "transition",
- component: () => import("../views/transition/index.vue"),
- },
- // 404 Page Not Found
- // {
- // path: "*",
- // name: "NotFound",
- // component: () => import("../views/error/404.vue"),
- // },
- ],
- });
- const router = createRouter();
- const originalPush = VueRouter.prototype.push;
- VueRouter.prototype.push = function push(location) {
- return originalPush.call(this, location).catch((err) => err);
- };
- // 重置路由
- export function resetRouter() {
- const newRouter = createRouter();
- router.matcher = newRouter.matcher; // reset router
- }
- router.beforeEach((to, from, next) => {
- if (to.matched.length === 0) {
- return next("/login");
- } else {
- next();
- }
- });
- export default router;
|