import Vue from "vue"; import VueRouter from "vue-router"; import Layout from "@/layouts"; import { publicPath, routerMode } from "@/config"; Vue.use(VueRouter); export const constantRoutes = [ { path: "/login", component: () => import("@/views/login/index"), hidden: true, }, { path: "/401", name: "401", component: () => import("@/views/401"), hidden: true, }, { path: "/404", name: "404", component: () => import("@/views/404"), hidden: true, }, ]; export const asyncRoutes = [ { path: "/", component: Layout, redirect: "/index", children: [ { path: "index", name: "Index", component: () => import("@/views/index/index"), meta: { title: "首页", icon: "home", affix: true, }, }, ], }, { path: "/project", component: Layout, redirect: "project", // name: 'Vab', // alwaysShow: true, children: [ { path: "index", component: () => import("@/views/project/index"), name: "Project", meta: { title: "项目", icon: "box-open", affix: true, }, }, ], }, { path: "/user", component: Layout, redirect: "user", // name: 'Vab', // alwaysShow: true, children: [ { path: "index", component: () => import("@/views/user/index"), name: "User", meta: { title: "用户", icon: "user", permissions: ["admin"], }, }, ], meta: { permissions: ["admin"] }, }, { path: "*", redirect: "/404", hidden: true, }, ]; const router = new VueRouter({ base: publicPath, mode: routerMode, scrollBehavior: () => ({ y: 0, }), routes: constantRoutes, }); export function resetRouter() { location.reload(); } export default router;