123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- import Vue from 'vue';
- import VueRouter from 'vue-router';
- import store from '@/store/index';
- import { Notification } from 'element-ui';
- Vue.use(VueRouter);
- const routes = [
- {
- path: '/',
- name: 'frame',
- component: () => import('@/views/index.vue'),
- children: [
- {
- path: '/plan/index',
- name: 'plan_list',
- meta: { title: '计划', sub: '列表' },
- component: () => import('@/views/plan/index.vue'),
- },
- {
- path: '/plan/detail',
- name: 'plan_detail',
- meta: { title: '计划', sub: '详情' },
- component: () => import('@/views/plan/detail.vue'),
- },
- {
- path: '/plan/classes',
- name: 'plan_classes',
- meta: { title: '授课班级' },
- component: () => import('@/views/plan/classes.vue'),
- },
- {
- path: '/plan/name/list',
- name: 'plan_name_list',
- meta: { title: '授课班级' },
- component: () => import('@/views/plan/classes/name-list.vue'),
- },
- {
- path: '/plan/class/info',
- name: 'plan_class_info',
- meta: { title: '班级信息' },
- component: () => import('@/views/plan/classes/info.vue'),
- },
- {
- path: '/lesson/index',
- name: 'lesson_index',
- meta: { title: '课程信息' },
- component: () => import('@/views/lesson/index.vue'),
- },
- {
- path: '/task/index',
- name: 'task_index',
- meta: { title: '作业管理' },
- component: () => import('@/views/task/index.vue'),
- },
- {
- path: '/task/taskList',
- name: 'task_taskList',
- meta: { title: '学生作业列表' },
- component: () => import('@/views/task/taskList.vue'),
- },
- {
- path: '/task/taskDetail',
- name: 'task_taskDetail',
- meta: { title: '学生作业详情' },
- component: () => import('@/views/task/taskDetail.vue'),
- },
- {
- path: '/class/index',
- name: 'class_index',
- meta: { title: '班级信息' },
- component: () => import('@/views/class/index.vue'),
- },
- {
- path: '/class/classStuList',
- name: 'class_classStuList',
- meta: { title: '学生名单' },
- component: () => import('@/views/class/classStuList.vue'),
- },
- // 在线授课
- {
- path: '/teaching/index',
- name: 'teaching_index',
- meta: { title: '直播讲课' },
- component: () => import('@/views/teaching/index.vue'),
- },
- {
- path: '/teaching/detail',
- name: 'teaching_detail',
- meta: { title: '直播讲课信息', sub: '管理' },
- component: () => import('@/views/teaching/detail.vue'),
- },
- {
- path: '/teaching/live',
- name: 'teaching_live',
- meta: { title: '直播讲课', sub: '管理' },
- component: () => import('@/views/teaching/live.vue'),
- },
- {
- path: '/teaching/afterClass',
- name: 'teaching_afterClass',
- meta: { title: '课后答疑', sub: '管理' },
- component: () => import('@/views/teaching/afterClass.vue'),
- },
- {
- path: '/teaching/afterClassDetail',
- name: 'teaching_afterClassDetail',
- meta: { title: '课后答疑', sub: '管理' },
- component: () => import('@/views/teaching/afterClassDetail.vue'),
- },
- {
- path: '/teaching/afterClassList',
- name: 'teaching_afterClassList',
- meta: { title: '答疑列表', sub: '管理' },
- component: () => import('@/views/teaching/afterClassList.vue'),
- },
- ],
- },
- {
- path: '/login',
- name: 'login',
- meta: { title: '登录', sub: '管理' },
- component: () => import('@/views/register/login.vue'),
- },
- ];
- const router = new VueRouter({
- mode: 'history',
- base: process.env.NODE_ENV === 'development' ? '' : 'teacher',
- routes,
- });
- router.beforeEach((to, form, next) => {
- store.commit('setUser');
- store.dispatch('setting/checkCache');
- if (to.name === 'login') {
- next();
- return;
- }
- let user = store.state.user;
- if (user) {
- if (user.type == process.env.VUE_APP_USER_TYPE) {
- console.log('已登录');
- next();
- } else {
- Notification({
- title: '请重新登陆',
- message: `原因:非当前端用户,需要重新登陆`,
- type: 'warning',
- });
- console.warn('非当前端用户,需要重新登陆');
- next({ name: 'login' });
- }
- }
- //下面是没登录的情况,需要跳转页面到用户未登录页
- else next({ name: 'login' });
- });
- export default router;
|