import Vue from "vue"; import Router from "vue-router"; import { PAGE_PATH } from "../config"; Vue.use(Router); const router = new Router({ mode: "hash", scrollBehavior: () => ({ x: 0, y: 0 }), routes: [ { path: "/", redirect: PAGE_PATH.user }, //用户 { path: PAGE_PATH.layout, redirect: PAGE_PATH.user, component: () => import("../views/Layout/index.vue"), children: [ { path: PAGE_PATH.user, component: () => import("../views/User/index.vue"), }, ], }, //角色 { path: PAGE_PATH.layout, component: () => import("../views/Layout/index.vue"), children: [ { path: PAGE_PATH.role, component: () => import("../views/Role/index.vue"), }, ], }, //菜单 { path: PAGE_PATH.layout, component: () => import("../views/Layout/index.vue"), children: [ { path: PAGE_PATH.menu, component: () => import("../views/Menu/index.vue"), }, ], }, //部门 { path: PAGE_PATH.layout, component: () => import("../views/Layout/index.vue"), children: [ { path: PAGE_PATH.department, component: () => import("../views/Department/index.vue"), }, ], }, //岗位 { path: PAGE_PATH.layout, component: () => import("../views/Layout/index.vue"), children: [ { path: PAGE_PATH.station, component: () => import("../views/Station/index.vue"), }, ], }, //字典 { path: PAGE_PATH.layout, component: () => import("../views/Layout/index.vue"), children: [ { path: PAGE_PATH.dict, component: () => import("../views/Dict/index.vue"), }, ], }, //参数 { path: PAGE_PATH.layout, component: () => import("../views/Layout/index.vue"), children: [ { path: PAGE_PATH.parameter, component: () => import("../views/Parameter/index.vue"), }, ], }, //日志 { path: PAGE_PATH.layout, redirect: PAGE_PATH.updateDaily, component: () => import("../views/Layout/index.vue"), children: [ { path: PAGE_PATH.updateDaily, component: () => import("../views/Daily/UpdateDaily/index.vue"), }, { path: PAGE_PATH.handleDaily, component: () => import("../views/Daily/HandleDaily/index.vue"), }, { path: PAGE_PATH.loginDaily, component: () => import("../views/Daily/LoginDaily/index.vue"), }, ], }, //编码 { path: PAGE_PATH.layout, component: () => import("../views/Layout/index.vue"), children: [ { path: PAGE_PATH.codeRules, component: () => import("../views/CodeRules/index.vue"), }, ], }, // { // path: PAGE_PATH.layout, // component: () => import("../views/Layout/index.vue"), // redirect: PAGE_PATH.user, // children: [ // { // path: PAGE_PATH.user, // // component: () => import("../views/User/index.vue"), // }, // { // path: PAGE_PATH.authority, // // component: () => import("../views/Authority/index.vue"), // } // ], // }, ], }); // router.beforeEach((to, from, next) => { // NProgress.start() // if(to.fullPath !== '/login' && !auth()){ // router.replace({ path: '/login'}) // return next() // } // next() // }) // router.beforeEach((to, from, next) => { // NProgress.start(); // if (to.fullPath !== "/login" && !auth()) { // next("/login"); // } else { // next(); // } // }); // router.afterEach(() => { // NProgress.done(); // }); export default router;