import Vue from "vue"; import Router from "vue-router"; Vue.use(Router); /* Layout */ import Layout from "@/layout"; /** * constantRoutes * a base page that does not have permission requirements * all roles can be accessed */ export const constantRoutes = [ { path: "/redirect", component: Layout, hidden: true, children: [ { path: "/redirect/:path(.*)", component: () => import("@/views/redirect/index"), }, ], }, { path: "/login", component: () => import("@/views/login/index"), hidden: true, }, { path: "/home", component: () => import("@/views/home/index"), hidden: true, }, { path: "/line_on_sale", component: () => import("@/views/home/line_on_sale"), hidden: true, }, { path: "/auth-redirect", component: () => import("@/views/login/auth-redirect"), hidden: true, }, { path: "/404", component: () => import("@/views/error-page/404"), hidden: true, }, { path: "/401", component: () => import("@/views/error-page/401"), hidden: true, }, { path: "/", component: Layout, redirect: "/dashboard", children: [ { path: "dashboard", component: () => import("@/views/dashboard/index"), name: "Dashboard", meta: { title: "系统面板", icon: "dashboard", affix: true }, }, ], }, ]; /** * asyncRoutes * the routes that need to be dynamically loaded based on user roles */ export const asyncRoutes = [ { path: "/system", component: Layout, redirect: "/system", alwaysShow: true, name: "System", meta: { title: "系统管理", icon: "el-icon-s-home", roles: ["admin"], }, children: [ { path: "admin", component: () => import("@/views/admin/index"), name: "Admin", meta: { title: "管理员", roles: ["admin"], }, }, { path: "works", component: () => import("@/views/admin/works"), name: "Works", meta: { title: "排班表", roles: ["admin"], }, }, { path: "scheduling", component: () => import("@/views/scheduling/index"), name: "scheduling", meta: { title: "直播排班", roles: ["admin"], }, }, { path: "onlines", component: () => import("@/views/onlines/online.vue"), name: "onlines", meta: { title: "在线客服", roles: ["admin"], }, }, { path: "proManagement", component: () => import("@/views/proManagement/index"), name: "ProManagement", meta: { title: "商品管理", roles: ["admin"], }, }, { path: "contract", component: () => import("@/views/proManagement/contract"), name: "ProManagementContract", meta: { title: "合同管理", roles: ["admin"], }, }, { path: "proScheduling", component: () => import("@/views/proManagement/scheduling"), name: "ProScheduling", meta: { title: "班期管理", roles: ["admin"], hidden: true, }, }, /*, { path: 'shortcut', component: () => import('@/views/shortcut/shortcutContent.vue'), name: 'shortcut', meta: { title: '快捷内容设置', roles: ['admin'] } }, { path: 'teams', component: () => import('@/views/admin/teams'), name: 'Teams', meta: { title: '团队', roles: ['admin'] } }*/ ], }, { path: "/order", component: Layout, redirect: "/order/index", alwaysShow: true, name: "Orders", meta: { title: "订单管理", icon: "money", roles: ["order_index", "editor"], }, children: [ { path: "index", component: () => import("@/views/order/index"), name: "OrderList", meta: { title: "订单列表", roles: ["order_pub", "editor"], }, }, /* { path: 'pub', component: () => import('@/views/order/pub'), name: 'OrderPub', meta: { title: '公海订单', roles: ['order_pub','editor'] } },*/ { path: "back", component: () => import("@/views/order/back"), name: "OrderBack", meta: { title: "流转订单", roles: ["order_back", "editor"], }, }, { path: "abandoned", component: () => import("@/views/order/abandoned"), name: "OrderBack", meta: { title: "已放弃订单", roles: ["order_back", "editor"], }, }, { path: "used", component: () => import("@/views/order/used"), name: "OrderBack", meta: { title: "已使用订单", roles: ["order_back", "editor"], }, }, { path: "refunded", component: () => import("@/views/order/refunded"), name: "OrderBack", meta: { title: "已退款订单", roles: ["order_back", "editor"], }, }, { path: "appointment", component: () => import("@/views/order/appointment"), name: "appointment", meta: { title: "预约记录", roles: ["order_back", "editor"], }, }, ], }, { path: "/qa", component: Layout, redirect: "/qa/qa", alwaysShow: true, name: "Qa", meta: { title: "QA管理", icon: "el-icon-question", roles: ["order_index", "editor", "franchisee"], }, children: [ { path: "problem", component: () => import("@/views/qa/problem.vue"), name: "problem", meta: { title: "QA常见问题", roles: ["order_pub", "editor", "franchisee"], }, }, { path: "qa", component: () => import("@/views/qa/qa.vue"), name: "qa", meta: { title: "QA管理列表", roles: ["admin"], }, }, { path: "city", component: () => import("@/views/qa/city.vue"), name: "city", meta: { title: "城市管理列表", roles: ["admin"], }, }, ], }, { path: "/data", component: Layout, redirect: "/data/index", alwaysShow: true, name: "Data", meta: { title: "数据统计", icon: "chart", roles: ["data_index"], }, children: [ { path: "product", component: () => import("@/views/order/product"), name: "productNameList", meta: { title: "产品统计", roles: ["order_pub", "editor"], }, }, { path: "index", component: () => import("@/views/data/index"), name: "Index", meta: { title: "跟进统计", roles: ["data_index"], }, }, /* { path: 'online', component: () => import('@/views/data/online'), name: 'Index', meta: { title: '在线时长', roles: ['data_online'] } }, { path: 'anchor', component: () => import('@/views/data/anchor'), name: 'Anchor', meta: { title: '主播概况', roles: ['data_anchor'] } },*/ { path: "sale", component: () => import("@/views/data/sale"), name: "Sale", meta: { title: "销售统计", roles: ["data_sale"], }, }, ], }, { path: "/log", component: Layout, redirect: "/log/index", alwaysShow: true, name: "Log", meta: { title: "日志记录", icon: "nested", roles: ["follow_index", "log_index", "editor", "franchisee"], }, children: [ { path: "follow", component: () => import("@/views/log/follow"), name: "Follow", meta: { title: "跟进记录", roles: ["follow_index", "editor", "franchisee"], }, }, { path: "index", component: () => import("@/views/log/index"), name: "LogIndex", meta: { title: "日志记录", roles: ["log_index"], }, }, ], }, { path: "/announcements", component: Layout, redirect: "/announcements/index", alwaysShow: true, name: "announcements", meta: { title: "公告管理", icon: "el-icon-s-promotion", roles: ["admin"], }, children: [ { path: "list", component: () => import("@/views/announcements/list"), name: "list", meta: { title: "公告列表", roles: ["admin"], }, }, ], }, { path: "/icon", component: Layout, children: [ { path: "index", component: () => import("@/views/icons/index"), name: "Icons", meta: { title: "Icons", icon: "icon", noCache: true }, }, ], }, // 404 page must be placed at the end !!! { path: "*", redirect: "/404", hidden: true }, ]; const createRouter = () => new Router({ // mode: 'history', // require service support scrollBehavior: () => ({ y: 0 }), routes: constantRoutes, }); const router = createRouter(); // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465 export function resetRouter() { const newRouter = createRouter(); router.matcher = newRouter.matcher; // reset router } export default router;