123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- import Vue from 'vue';
- import VueRouter from 'vue-router';
- import login from '@/views/login';
- import Layout from '@/layouts';
- import store from '@/store';
- import NProgress from 'nprogress';
- import { Message } from 'element-ui';
- Vue.use(VueRouter);
- function isHasPopedom(code) {
- return store.state.user.popedom_code_list.indexOf(code) !== -1;
- }
- function jumpURL() {
- if (isHasPopedom(1000001)) {
- return '/org_manager';
- }
- if (isHasPopedom(1000002)) {
- return '/account_manager/index';
- }
- if (isHasPopedom(1000003)) {
- return '/teacher_manager/index';
- }
- return '/login';
- }
- // 路由独享的守卫的权限控制
- function beforeRouterPopedom(code, next) {
- if (isHasPopedom(code)) {
- next();
- } else {
- Message({
- type: 'warning',
- message: '无权限'
- });
- store.dispatch('user/signOut');
- next('/login');
- NProgress.done();
- }
- }
- const routes = [
- {
- path: '/login',
- component: login
- },
- {
- path: '/jump',
- redirect: () => jumpURL()
- },
- {
- path: '/404',
- component: () => import('@/views/404')
- },
- {
- path: '/',
- component: Layout,
- redirect: { name: 'OrgManager' },
- meta: { title: '机构管理', path: '/org_manager' },
- children: [
- {
- path: '/org_manager',
- name: 'OrgManager',
- component: () => import('@/views/org_manager'),
- beforeEnter: (to, form, next) => {
- beforeRouterPopedom(1000001, next);
- }
- },
- {
- path: '/add_org',
- meta: { title: '创建机构' },
- component: () => import('@/views/org_manager/AddOrg'),
- beforeEnter: (to, form, next) => {
- beforeRouterPopedom(1000001, next);
- }
- },
- {
- path: '/free_license/:org_id',
- meta: { title: '教材授权' },
- component: () => import('@/views/org_manager/FreeLicense.vue'),
- beforeEnter: (to, form, next) => {
- beforeRouterPopedom(1000001, next);
- }
- }
- ]
- },
- {
- path: '/account_manager',
- component: Layout,
- meta: { title: '账户管理' },
- redirect: { name: 'AccountManager' },
- children: [
- {
- path: 'index',
- name: 'AccountManager',
- component: () => import('@/views/account_manager'),
- beforeEnter: (to, form, next) => {
- beforeRouterPopedom(1000002, next);
- }
- }
- ]
- },
- {
- path: '/teacher_manager',
- component: Layout,
- meta: { title: '机构教师' },
- redirect: { name: 'TeacherManager' },
- children: [
- {
- path: 'index',
- name: 'TeacherManager',
- component: () => import('@/views/teacher_manager'),
- beforeEnter: (to, form, next) => {
- beforeRouterPopedom(1000003, next);
- }
- }
- ]
- },
- {
- path: '/student_manager',
- component: Layout,
- meta: { title: '机构学生' },
- redirect: { name: 'StudentManager' },
- children: [
- {
- path: 'index',
- name: 'StudentManager',
- component: () => import('@/views/student_manager'),
- beforeEnter: (to, form, next) => {
- beforeRouterPopedom(1000003, next);
- }
- }
- ]
- },
- {
- path: '/vocabulary',
- component: Layout,
- meta: { title: '多语言词汇' },
- redirect: '/vocabulary/index',
- children: [
- {
- path: 'index',
- component: () => import('@/views/vocabulary/index')
- },
- {
- path: '/vocabDetail',
- component: () => import('@/views/vocabulary/vocabDetail')
- }
- ]
- },
- {
- path: '/uploadList',
- component: Layout,
- meta: { title: '文件静态资源' },
- redirect: '/upload/uploadList',
- children: [
- {
- path: '/upload/uploadList',
- component: () => import('@/views/upload/uploadList')
- },
- {
- path: '/uploadDetail',
- component: () => import('@/views/upload/uploadDetail'),
- meta: { title: '文件详情' }
- }
- ]
- },
- {
- path: '/settings',
- component: Layout,
- meta: { title: '系统配置' },
- redirect: '/settings/index/LiveRoomConfig',
- children: [
- {
- path: 'index',
- component: () => import('@/views/settings'),
- children: [
- {
- path: 'LiveRoomConfig',
- meta: {
- name: 'LiveRoomConfig'
- },
- components: {
- // 命名视图
- configure: () => import('@/views/settings/configure/LiveRoomConfig.vue')
- }
- },
- {
- path: 'SXYZFConfig',
- meta: {
- name: 'SXYZFConfig'
- },
- components: {
- configure: () => import('@/views/settings/configure/SXYZFConfig.vue')
- }
- },
- {
- path: 'MailboxConfig',
- meta: {
- name: 'MailboxConfig'
- },
- components: {
- configure: () => import('@/views/settings/configure/MailboxConfig.vue')
- }
- },
- {
- path: 'ShareConfig',
- meta: {
- name: 'ShareConfig'
- },
- components: {
- configure: () => import('@/views/settings/configure/ShareConfig.vue')
- }
- },
- {
- path: 'SpeechEngine',
- meta: {
- name: 'SpeechEngine'
- },
- components: {
- configure: () => import('@/views/settings/configure/SpeechEngine.vue')
- }
- }
- ]
- }
- ]
- },
- {
- path: '/quota',
- component: Layout,
- meta: { title: '配额管理', path: '/quota' },
- redirect: '/quota/index',
- children: [
- {
- path: 'index',
- component: () => import('@/views/quota')
- },
- {
- path: 'usageRecord/:orgId/:orgName',
- component: () => import('@/views/quota/UsageRecord.vue'),
- meta: { title: '' },
- props: true,
- beforeEnter: ({ meta, params }, from, next) => {
- meta.title = params.orgName;
- next();
- }
- },
- {
- path: 'liveDetail/:orgId/:taskId/:orgName',
- component: () => import('@/views/quota/LiveDetail.vue'),
- meta: { title: '' },
- props: true,
- beforeEnter: ({ meta, params }, from, next) => {
- meta.title = params.orgName;
- next();
- }
- }
- ]
- },
- {
- path: '/oboc',
- component: Layout,
- meta: { title: '教材链接', path: '/oboc' },
- redirect: '/oboc/index',
- children: [
- {
- path: 'index',
- component: () => import('@/views/oboc')
- }
- ]
- },
- {
- path: '/log',
- component: Layout,
- meta: { title: '操作日志' },
- redirect: '/log/index',
- children: [
- {
- path: 'index',
- component: () => import('@/views/log/index.vue')
- }
- ]
- },
- {
- path: '*',
- redirect: '/404'
- }
- ];
- const createRouter = () =>
- new VueRouter({
- // mode: 'history',
- scrollBehavior: () => ({ y: 0 }),
- routes
- });
- const router = createRouter();
- // 重置路由
- export function resetRouter() {
- const newRouter = createRouter();
- router.matcher = newRouter.matcher;
- }
- export default router;
|