| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- import Vue from 'vue'
- import VueRouter from 'vue-router'
- import Layout from '@/views/Layout.vue'
- import { isAllowed, defaultPath } from '@/config/menu-roles.js'
- Vue.use(VueRouter)
- const routes = [
- {
- path: '/login',
- name: 'Login',
- component: () => import('@/views/Login.vue'),
- meta: { title: '登录' }
- },
- {
- path: '/screen',
- name: 'Screen',
- component: () => import('@/views/Screen.vue'),
- meta: { title: '课程现场投屏' }
- },
- {
- path: '/',
- component: Layout,
- redirect: '/dashboard',
- children: [
- {
- path: 'dashboard',
- name: 'Dashboard',
- component: () => import('@/views/Dashboard.vue'),
- meta: { title: '概览' }
- },
- {
- path: 'courses',
- name: 'Courses',
- component: () => import('@/views/Courses.vue'),
- meta: { title: '课程管理' }
- },
- {
- path: 'modules',
- name: 'Modules',
- component: () => import('@/views/Modules.vue'),
- meta: { title: '模块管理' }
- },
- {
- path: 'classes',
- name: 'Classes',
- component: () => import('@/views/Classes.vue'),
- meta: { title: '班级管理' }
- },
- {
- path: 'salons',
- name: 'Salons',
- component: () => import('@/views/Salons.vue'),
- meta: { title: '沙龙管理' }
- },
- {
- path: 'members',
- name: 'Members',
- component: () => import('@/views/Members.vue'),
- meta: { title: '会员台账' }
- },
- {
- path: 'enrollments',
- name: 'Enrollments',
- component: () => import('@/views/Enrollments.vue'),
- meta: { title: '报名管理' }
- },
- {
- path: 'orders',
- name: 'Orders',
- component: () => import('@/views/Orders.vue'),
- meta: { title: '订单管理' }
- },
- {
- path: 'group-orders',
- name: 'GroupOrders',
- component: () => import('@/views/GroupOrders.vue'),
- meta: { title: '团报管理' }
- },
- {
- path: 'cases',
- name: 'Cases',
- component: () => import('@/views/Cases.vue'),
- meta: { title: '案例管理' }
- },
- {
- path: 'groups',
- name: 'Groups',
- component: () => import('@/views/Groups.vue'),
- meta: { title: '分组管理' }
- },
- {
- path: 'invites',
- name: 'Invites',
- component: () => import('@/views/Invites.vue'),
- meta: { title: '转介绍漏斗' }
- },
- {
- path: 'materials',
- name: 'Materials',
- component: () => import('@/views/Materials.vue'),
- meta: { title: '课前资料' }
- },
- {
- path: 'users',
- name: 'Users',
- component: () => import('@/views/Users.vue'),
- meta: { title: '学员管理' }
- },
- {
- path: 'review/submissions',
- name: 'Submissions',
- component: () => import('@/views/Submissions.vue'),
- meta: { title: '成果审核' }
- },
- {
- path: 'review/cards',
- name: 'Cards',
- component: () => import('@/views/Cards.vue'),
- meta: { title: '教学卡评分' }
- },
- {
- path: 'review/roadmaps',
- name: 'Roadmaps',
- component: () => import('@/views/Roadmaps.vue'),
- meta: { title: '路演评审' }
- },
- {
- path: 'scoreboard',
- name: 'Scoreboard',
- component: () => import('@/views/Scoreboard.vue'),
- meta: { title: '积分榜' }
- },
- {
- path: 'manual-score',
- name: 'ManualScore',
- component: () => import('@/views/ManualScore.vue'),
- meta: { title: '人工加减分' }
- },
- {
- path: 'stats',
- name: 'Stats',
- component: () => import('@/views/Stats.vue'),
- meta: { title: '统计' }
- }
- ]
- }
- ]
- const router = new VueRouter({
- mode: 'history',
- base: process.env.BASE_URL,
- routes
- })
- router.beforeEach(function (to, from, next) {
- document.title = (to.meta && to.meta.title ? to.meta.title + ' - ' : '') + '爱伴·AI之旅 管理后台'
- var token = localStorage.getItem('token')
- if (to.path === '/login') {
- if (token) {
- return next('/dashboard')
- }
- return next()
- }
- if (!token) {
- return next('/login')
- }
- // 角色越权检查:非授权菜单访问 → 重定向到该角色默认页
- var role = localStorage.getItem('role') || 'admin'
- if (!isAllowed(role, to.path)) {
- return next(defaultPath(role))
- }
- next()
- })
- // Suppress navigation guard redirect errors
- var originalPush = VueRouter.prototype.push
- VueRouter.prototype.push = function push(location) {
- return originalPush.call(this, location).catch(function (err) { return err })
- }
- export default router
|