12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import Vue from 'vue';
- import VueRouter from 'vue-router';
- import store from '@/store/index';
- Vue.use(VueRouter);
- const routes = [
- {
- path: '/',
- name: 'index',
- meta: { title: '班级列表', isleftarrow: false },
- component: () => import('../views/index.vue'),
- },
- // 班级首页
- {
- path: '/home/index',
- name: 'home_index',
- meta: { title: '班级首页', isleftarrow: true },
- component: () => import('../views/home/index.vue'),
- },
- // 班级首页
- {
- path: '/home/teacher',
- name: 'home_teacher',
- meta: { title: '班级首页', isleftarrow: true },
- component: () => import('../views/home/teacher.vue'),
- },
- // 班级名单
- {
- path: '/class/index',
- name: 'class_index',
- meta: { title: '班级名单', isleftarrow: true },
- component: () => import('../views/class/index.vue'),
- },
- // 调查问卷
- {
- path: '/question/index',
- name: 'question_index',
- meta: { title: '调查问卷', isleftarrow: true },
- component: () => import('../views/question/index.vue'),
- },
- // 个人中心
- {
- path: '/user/index',
- name: 'user_index',
- meta: { title: '个人中心', isleftarrow: true },
- component: () => import('../views/user/index.vue'),
- },
- ];
- const router = new VueRouter({
- routes,
- });
- router.beforeEach((to, form, next) => {
- store.commit('setUser');
- store.commit('setClass');
- let user = store.state.user;
- if (user) {
- console.log('已登录');
- }
- //下面是没登录的情况,需要跳转页面到用户未登录页
- else console.log('未登录');
- next();
- });
- export default router;
|