import Vue from 'vue'; import Router from 'vue-router'; Vue.use(Router); /* Layout */ import Layout from '@/layout'; /** * Note: sub-menu only appear when route children.length >= 1 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html * * hidden: true if set true, item will not show in the sidebar(default is false) * alwaysShow: true if set true, will always show the root menu * if not set alwaysShow, when item has more than one children route, * it will becomes nested mode, otherwise not show the root menu * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb * name:'router-name' the name is used by (must set!!!) * meta : { roles: ['admin','editor'] control the page roles (you can set multiple roles) title: 'title' the name show in sidebar and breadcrumb (recommend set) icon: 'svg-name' the icon show in the sidebar breadcrumb: false if set false, the item will hidden in breadcrumb(default is true) activeMenu: '/example/list' if set path, the sidebar will highlight the path you set } */ export const user = '01'; // 普通用户 export const mapCreater = '02'; // 地图创建权限 export const lessonCreater = '03'; // 课程创建权限 export const admin = '04'; // 管理员 export const superAdmin = '05'; // 超级管理员 export const userExam = '011'; // 考试系统 export const userLesson = '012'; // 教学系统 export const userSimulation = '013'; // 仿真系统 export const userScreen = '014'; // 大屏系统 export const userPlan = '015'; // 计划系统 export const UrlConfig = { display: '/display', examRuleDraft: '/examRule/draft', examRuleManage: '/examRule/manage', map: { prefix: '/map', draft: '/map/draw', skinStyle: '/map/skinStyle', skinStyleDraft: '/map/skinStyle/draft', runPlan: '/map/runPlan', runPlanView: '/map/runPlan/view', product: '/map/product', productDraft: '/map/product/draft' }, lesson: { prefix: '/lesson', record: '/lesson/record/training', manage: '/lesson/manage/training' }, teach: { prefix: '/teach', detail: '/teach/detail', practical: '/teach/practical', pay: '/teach/pay' }, exam: { prefix: '/exam', detail: '/exam/detail', course: '/exam/course', examRuleManage: '/exam/examRule/manage', pay: '/exam/pay' }, demonstration: { prefix: '/demonstration', detail: '/demonstration/detail', pay: '/demonstration/pay' }, dp: { prefix: '/dp', detail: '/dp/detail', pay: '/dp/pay' }, plan: { prefix: '/plan', tool: '/plan/tool', detail: '/plan/detail', pay: '/plan/pay' }, replay: { prefix: '/replay' }, permission: { prefix: '/permission', permissionList: '/permission/manage', permissionDraft: '/permission/draft', permission: '/permission/restore' }, publish: { prefix: '/publish', map: '/publish/map', mapDraft: '/publish/map/draft', runPlanEveryDay: '/publish/runPlan/everyDay', runPlanTemplate: '/publish/runPlan/template', runPlanCommon: '/publish/runPlan/common', runPlanView: '/publish/runPlan/view' }, orderauthor: { prefix: '/orderauthor', commodityManage: '/orderauthor/commodity/manage', commodityDraft: '/orderauthor/commodity/draft', orderManage: '/orderauthor/order/manage', orderDraft: '/orderauthor/order/draft', authorMange: '/orderauthor/author/manage', authorDraft: '/orderauthor/author/draft', transferDetail: '/orderauthor/transfer/detail', trainferPackage: '/orderauthor/transfer/package' } }; /** * constantRoutes * a base page that does not have permission requirements * all roles can be accessed */ export const constantRoutes = [ { path: '/login', components: import('@/views/login/loginNew'), hidden: true }, { path: '/login1', components: import('@/views/login/index'), hidden: true }, // 扫码登录 { path: '/dp/login', components: import('@/views/login/loginNewScreen'), hidden: true }, // 密码登录 { path: '/dp/login1', components: import('@/views/login/loginScreen'), hidden: true }, // 扫码登录 { path: '/plan/login', components: import('@/views/login/loginNewPlan'), hidden: true }, // 密码登录 { path: '/plan/login1', components: import('@/views/login/loginPlan'), hidden: true }, { path: '/jlmap3d/edit', components: import('@/views/jlmap3d/jlmap3dedit'), hidden: true }, { path: '/401', components: import('@/views/error-page/401'), hidden: true }, { path: '/404', components: import('@/views/error-page/404'), hidden: true }, { path: '/', components: Layout, redirect: '/dashboard', children: [{ path: 'dashboard', components: import('@/views/dashboard/index'), meta: { i18n: 'router.homePage', icon: 'dashboard' } }] }, { path: '*', redirect: '/404', hidden: true } ]; export const asyncRouter = [ { path: '/', components: Layout, redirect: '/dashboard', hidden: true, children: [ { path: 'dashboard', components: import('@/views/dashboard/index.vue') } ] }, { path: '/display/:mode', components: import('@/views/display/index'), meta: { }, hidden: true }, { path: '/trainroom', components: import('@/views/trainRoom/index'), meta: { }, hidden: true }, { path: '/jointTraining', components: import('@/views/jointTraining/index'), hidden: true }, { path: '/jlmap3d', components: import('@/views/jlmap3d/index'), meta: { }, hidden: true }, { path: '/map', meta: { i18n: 'router.mapManage', roles: [admin, mapCreater] }, components: Layout, children: [ { path: 'skinStyle', components: import('@/views/map/skinStyle/index'), meta: { i18n: 'router.skinManage' } }, { path: 'skinStyle/draft/:mode/:skinStyleId', hidden: true, components: import('@/views/map/skinStyle/draft') }, { path: 'draw', redirect: '/map/draw/0/draft', components: import('@/views/map/mapdraft/index'), meta: { i18n: 'router.mapDraw' }, children: [ { path: ':mapId/:view', components: import('@/views/map/mapdraft/mapedit/index'), hidden: true } ] }, { path: 'runPlan', redirect: '/map/runPlan/view/draft', components: import('@/views/map/runplan/index'), meta: { i18n: 'router.runPlanManage' }, children: [{ path: 'view/:mode', components: import('@/views/map/runplan/chart'), hidden: true }] }, { path: 'product', components: import('@/views/lesson/trainingcategory/index'), meta: { i18n: 'router.productEdit' } } ] }, { path: '/lesson', components: Layout, meta: { i18n: 'router.lessaonManage', roles: [admin, lessonCreater] }, children: [ { path: 'record', redirect: '/lesson/record/training/0/null', components: import('@/views/lesson/trainingrecord/index'), meta: { i18n: 'router.trainingRecord' }, children: [ { path: 'training/:trainingId/:trainingName', components: import('@/views/lesson/trainingrecord/manage/index'), hidden: true } ] }, { path: 'manage/taskManage', components: import('@/views/lesson/taskmanage/list'), meta: { i18n: 'router.taskManage' } }, { path: 'manage/trainingRule', components: import('@/views/lesson/trainingRule/list'), meta: { i18n: 'router.trainingRule' } }, { path: 'manage/trainingRule/detail', hidden: true, components: import('@/views/lesson/trainingRule/detail/index'), meta: { } }, { path: 'manage/training', components: import('@/views/lesson/trainingmanage/index'), meta: { i18n: 'router.trainingManage' } }, { path: 'edit', components: import('@/views/lesson/lessoncategory/index'), meta: { i18n: 'router.lessonEdit' } } ] }, { path: '/script', components: Layout, meta: { roles: [admin, lessonCreater] }, children: [ { path: 'scriptManage', components: import('@/views/lesson/scriptmanage/list'), meta: { i18n: 'router.scriptManage' } } ] }, { path: '/teach', redirect: '/teach/home', components: import('@/views/teach/index'), meta: { roles: [admin, userLesson, user] }, children: [ { path: 'home', components: import('@/views/teach/home'), meta: { i18n: 'router.teachSystem' } }, { // 课程详情 path: 'detail/:lessonId', components: import('@/views/teach/detail/index'), meta: { }, hidden: true }, { // 实训详情 path: 'practical/:trainingId/:lessonId', components: import('@/views/teach/practical/index'), meta: { }, hidden: true }, { path: 'pay/:lessonId', components: import('@/views/components/pay/index'), meta: { }, hidden: true } ] }, { path: '/exam', redirect: '/exam/home', components: import('@/views/exam/index'), meta: { roles: [admin, userExam, user] }, children: [ { path: 'home', components: import('@/views/exam/home'), meta: { i18n: 'router.examSystem' } }, { // 试卷详情 path: 'detail/:examId', components: import('@/views/exam/detail/examDetail'), hidden: true }, { path: 'course/:lessonId', components: import('@/views/exam/detail/courseDetail'), hidden: true }, { // 规则管理 path: 'examRule/manage', components: import('@/views/publish/examRule/index'), hidden: true }, { path: 'examRule/draft/:mode/:ruleId/:lessonId', hidden: true, components: import('@/views/publish/examRule/draft/index') }, { path: 'pay/:lessonId', components: import('@/views/components/pay/index'), hidden: true }, { // 开始考试 path: 'questionDetail/:examQuestionId', components: import('@/views/exam/detail/questionDetail'), hidden: true }, { // 考试结果 path: 'result/:userExamId', components: import('@/views/exam/result'), hidden: true } ] }, { path: '/demonstration', redirect: '/demonstration/home', components: import('@/views/demonstration/index'), meta: { roles: [admin, userSimulation, user] }, children: [ { path: 'home', components: import('@/views/demonstration/home'), meta: { i18n: 'router.demonstrationSystem' } }, { path: 'detail/:mapId', components: import('@/views/demonstration/detail/index'), hidden: true }, { path: 'pay/:lessonId', components: import('@/views/components/pay/index'), hidden: true } ] }, { path: '/dp', redirect: '/dp/home', components: import('@/views/screenMonitor/index'), meta: { roles: [admin, userScreen, user] }, children: [ { path: 'home', components: import('@/views/screenMonitor/home'), meta: { i18n: 'router.dpSystem' }, target: true }, { path: 'detail/:lessonId', components: import('@/views/screenMonitor/detail/index'), hidden: true }, { path: 'pay/:lessonId', components: import('@/views/components/pay/index'), hidden: true } ] }, { path: '/plan/tool', components: import('@/views/planMonitor/editTool/index'), meta: { }, hidden: true }, { path: '/plan', redirect: '/plan/home', components: import('@/views/planMonitor/index'), meta: { roles: [admin, user] }, children: [ { path: 'home', components: import('@/views/planMonitor/home'), meta: { i18n: 'router.planSystem' }, target: true }, { path: 'detail/:lessonId', components: import('@/views/planMonitor/detail'), hidden: true }, { path: 'pay/:lessonId', components: import('@/views/components/pay/index'), hidden: true } ] }, { path: '/replay', components: Layout, meta: { roles: [admin] }, children: [ { path: 'manage', components: import('@/views/replay/index'), meta: { i18n: 'router.replayManage' } } ] }, { path: '/permission', components: Layout, meta: { roles: [admin, user] }, children: [ { path: 'manage', components: import('@/views/package/index'), meta: { i18n: 'router.permissionManage' } }, { path: 'draft', components: import('@/views/package/draft/ruleForm'), hidden: true } ] }, { path: '/publish', components: Layout, meta: { i18n: 'router.pulishManage', roles: [admin] }, children: [ { path: 'map', components: import('@/views/publish/publishMap/index'), meta: { i18n: 'router.publishMapManage' } }, { path: 'product', components: import('@/views/publish/productStatus/index'), meta: { i18n: 'router.productStateManage' } }, { path: 'lesson', components: import('@/views/publish/publishLesson/index'), meta: { i18n: 'router.publishLessonManage' } }, // { // path: 'script', // components: import('@/views/publish/simulationScript/index'), // meta: { // title: '仿真脚本管理', // } // }, { path: 'runPlan/template', components: import('@/views/publish/runPlanTemplate/index'), meta: { i18n: 'router.runPlanTemplateManage' } }, { path: 'runPlan/common', components: import('@/views/publish/runPlanCommon/index'), meta: { i18n: 'router.runPlanCommonManage' } }, { path: 'runPlan/everyDay', components: import('@/views/publish/runPlanEveryDay/index'), meta: { i18n: 'router.runPlanEveryDayManage' } }, { path: 'examRule/manage', components: import('@/views/publish/examRule/index'), meta: { i18n: 'router.examRuleManage' } }, { path: 'map/draft/:mode/:mapId', components: import('@/views/publish/publishMap/draft'), hidden: true }, { path: 'examRule/draft/:mode/:ruleId/:lessonId', components: import('@/views/publish/examRule/draft/index'), hidden: true }, { path: 'runPlan/common/:mode', components: import('@/views/publish/runPlanCommon/draft'), hidden: true }, { path: 'runPlan/view/:mode', components: import('@/views/map/runplan/chart'), hidden: true } ] }, { path: '/orderauthor', components: Layout, meta: { i18n: 'router.orderAuthorityManage', roles: [admin] }, children: [ { path: 'commodity/manage', components: import('@/views/orderauthor/commodity/index'), meta: { i18n: 'router.commodityManage' } }, { path: 'order/manage', components: import('@/views/orderauthor/order/list'), meta: { i18n: 'router.orderManage' } }, { path: 'author/manage', components: import('@/views/orderauthor/author/index'), meta: { i18n: 'router.authorityManage' } }, { path: 'transfer/manage', components: import('@/views/orderauthor/permission/index'), meta: { i18n: 'router.authorityTransferManage' } }, { path: 'commodity/draft/:mode/:commodityId', hidden: true, components: import('@/views/orderauthor/commodity/draft'), meta: { i18n: 'router.addCommodity' } }, { path: 'order/draft/:mode/:orderId', hidden: true, components: import('@/views/orderauthor/order/draft'), meta: { i18n: 'router.addOrder' } }, { path: 'author/draft/:mode/:userId', hidden: true, components: import('@/views/orderauthor/author/draft'), meta: { i18n: 'router.addCoursePermissions' } }, { path: 'transfer/detail/:permissionId', components: import('@/views/orderauthor/permission/detail'), hidden: true }, { path: 'transfer/package', components: import('@/views/orderauthor/permission/draft/ruleForm'), hidden: true } ] }, { path: '/system', components: Layout, meta: { i18n: 'router.systemManage', roles: [admin] }, children: [ { path: 'dictionary', components: import('@/views/management/dictionary/index'), meta: { i18n: 'router.dataDictionary' } }, { path: 'dictionary/detail', hidden: true, components: import('@/views/management/dictionaryDetail/index'), meta: { i18n: 'router.dataDictionaryDetails' } }, { path: 'userManage', components: import('@/views/management/userControl/index'), meta: { i18n: 'router.userManage' } }, { path: 'userTrainingManage', components: import('@/views/management/userTraining/index'), meta: { i18n: 'router.userTrainingManage' } }, { path: 'userExamManage', components: import('@/views/management/userExam/index'), meta: { i18n: 'router.userExamManage' } }, { path: 'userSimulationManage', components: import('@/views/management/userSimulation/index'), meta: { i18n: 'router.userSimulationManage' } }, { path: 'existingSimulation', components: import('@/views/management/existingSimulation/index'), meta: { i18n: 'router.existingSimulation' } } ] } ]; const createRouter = () => new Router({ mode: 'history', // require service support scrollBehavior: () => ({ y: 0 }), routes: constantRoutes }); const router = createRouter(); router.beforeEach((to, from, next) => { const name = to.fullPath; if (name.includes('/dp/') || name.includes('display/dp')) { document.title = '琏课堂-大屏系统'; } else if (name.includes('/plan/') || name.includes('/planEdit/')) { document.title = '琏计划'; } else { document.title = '琏课堂'; } next(); }); export default router;