index.js 8.5 KB
import en from "../i18n/lang/en"
import Vue from "vue"
import Router from "vue-router"
import Login from "@/views/login/index"
import Layout from "@/views/layout/layout"
import HomeMain from "@/views/index/mainIndex"


// 不是必须加载的组件使用懒加载
const NotFound = () => import("@/views/page404")
const ExaminationPaper = () => import("@/views/examinationPaper/index")
const ExaminationPaperAdd = () => import("@/views/examinationPaper/add")
const ExaminationPaperEdit = () => import("@/views/examinationPaper/edit")
const ExaminationPaperRecycle = () => import("@/views/examinationPaper/recycle")
const Ask = () => import("@/views/ask/index")
const AskAnalysis = () => import("@/views/ask/analysis")
const Test = () => import("@/views/test/index")
const TestAnalysis = () => import("@/views/test/analysis")
const DataSync = () => import("@/views/dataSync/index")
const Portrait = () => import("@/views/portrait/index")
const Card = () => import("@/views/card/index")
const Analysis = () => import("@/views/analysis/index")
const Device = () => import("@/views/device/index")
const DeviceLog = () => import("@/views/device/log")
const Down = () => import("@/views/down/index")
const DownClient = () => import("@/views/down/client")
const SetUpAccount = () => import("@/views/setUp/account")
const SetUpConglomerate = () => import("@/views/setUp/conglomerate")
const SetUpSchool = () => import("@/views/setUp/school")
const SetUpStudent = () => import("@/views/setUp/student")
const SetUpTeacher = () => import("@/views/setUp/teacher")

/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}
Vue.use(Router)
let routeName = en.routeName
let defaultRouter = [
  {
    path: "/",
    redirect: "/index",
    hidden: true,
    children: []
  },
  {
    path: "/login",
    component: Login,
    name: "登录",
    hidden: true,
    children: []
  },
  {
    path: "/index",
    iconCls: "fa fa-home", // 图标样式class
    name: "应用首页",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/index",
        iconCls: "fa fa-dashboard", // 图标样式class
        name: "主页",
        component: HomeMain,
        children: []
      }
    ]
  },
  {
    path: "/404",
    component: NotFound,
    name: "404",
    hidden: true,
    children: []
  }
]

let addrouters = [  //测试用,后续后端获取
  {
    path: "/examinationPaper",
    iconCls: "fa fa-file-text", // 图标样式class
    name: "备题组卷",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/examinationPaper",
        iconCls: "fa fa-file-text", // 图标样式class
        name: "examinationPaper",
        component: ExaminationPaper,
        children: []
      },
      {
        path: "/examinationPaperAdd",
        iconCls: "", // 图标样式class
        name: "examinationPaperAdd",
        component: ExaminationPaperAdd,
        parent: "examinationPaper",
        children: []
      },
      {
        path: "/examinationPaperEdit",
        iconCls: "", // 图标样式class
        name: "修改答题卡",
        component: ExaminationPaperEdit,
        parent: "examinationPaper",
        children: []
      },
      {
        path: "/examinationPaperRecycle",
        iconCls: "", // 图标样式class
        name: "已归档答题卡",
        component: ExaminationPaperRecycle,
        parent: "examinationPaper",
        children: []
      },
    ]
  },
  {
    path: "/ask",
    iconCls: "fa fa-bar-chart", // 图标样式class
    name: "随堂问报表",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/ask",
        iconCls: "fa fa-bar-chart", // 图标样式class
        name: "ask",
        name: "随堂问报表",
        component: Ask,
        meta: {
          keepAlive: true,
        },
        children: []

      },
      {
        path: "/askAnalysis",
        iconCls: "", // 图标样式class
        name: "随堂问报表分析",
        component: AskAnalysis,
        parent: "ask",
        children: []
      }
    ]
  },
  {
    path: "/test",
    iconCls: "fa fa-pie-chart", // 图标样式class
    name: "即时测报表",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/test",
        iconCls: "fa fa-pie-chart", // 图标样式class
        name: "",
        component: Test,
        meta: {
          keepAlive: true,
        },
        children: []
      },
      {
        path: "/testAnalysis",
        iconCls: "", // 图标样式class
        name: "即时测报表分析",
        component: TestAnalysis,
        parent: "test",
        children: []
      }

    ]
  },
  // {
  //   path: "/portrait",
  //   iconCls: "fa fa-users", // 图标样式class
  //   name: "学生画像",
  //   component: Layout,
  //   alone: true,
  //   children: [
  //     {
  //       path: "/portrait",
  //       iconCls: "fa fa-users", // 图标样式class
  //       name: "",
  //       component: Portrait,
  //       children: []
  //     }
  //   ]
  // },

  {
    path: "/setUpConglomerate",
    iconCls: "fa fa-building", // 图标样式class
    name: "学校管理",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/setUpConglomerate",
        iconCls: "fa fa-building",
        name: '集团管理',
        component: SetUpConglomerate,
        children: []
      },
    ]
  },
  {
    path: "/setUpAccount",
    iconCls: "fa fa-id-card-o", // 图标样式class
    name: "账号管理",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/setUpAccount",
        iconCls: "fa fa-id-card-o",
        name: '',
        component: SetUpAccount,
        children: []
      },
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-cog",
    name: '学校管理',
    component: Layout,
    children: [
      {
        path: "/setUpSchool",
        iconCls: "fa fa-calculator",
        name: '学校设置',
        component: SetUpSchool,
        children: []
      },
      {
        path: "/setUpTeacher",
        iconCls: "fa fa-male",
        name: '教师管理',
        component: SetUpTeacher,
        children: []
      },
      {
        path: "/setUpStudent",
        iconCls: "fa fa-mortar-board",
        name: '学生管理',
        component: SetUpStudent,
        children: []
      },
    ]
  },
  {
    path: "/card",
    iconCls: "fa fa-id-card", // 图标样式class
    name: "发卡记录",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/card",
        iconCls: "fa fa-id-card", // 图标样式class
        name: "",
        component: Card,
        children: []
      }
    ]
  },
  {
    path: "/device",
    iconCls: "fa fa-dashboard", // 图标样式class
    name: "设备状态",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/device",
        iconCls: "fa fa-dashboard", // 图标样式class
        name: "",
        component: Device,
        meta: {
          keepAlive: true,
        },
        children: []
      },
      {
        path: "/deviceLog",
        iconCls: "fa fa-list-alt", // 图标样式class
        name: "",
        component: DeviceLog,
        parent: "device",
        children: []
      }
    ]
  },
  {
    path: "/analysis",
    iconCls: "fa fa-area-chart", // 图标样式class
    name: "使用分析",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/analysis",
        iconCls: "fa fa-area-chart", // 图标样式class
        name: "",
        component: Analysis,
        children: []
      }
    ]
  },
  {
    path: "/down",
    iconCls: "fa fa-download", // 图标样式class
    name: "软件下载",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/down",
        iconCls: "fa fa-download", // 图标样式class
        name: "发卡软件",
        component: Down,
        children: []
      },
      {
        path: "/downClient",
        iconCls: "", // 图标样式class
        name: "授课端软件",
        component: DownClient,
        parent: "down",
        children: []
      }
    ]
  },
  {
    path: "/dataSync",
    iconCls: "fa fa-random", // 图标样式class
    name: "数据同步",
    component: Layout,
    alone: true,
    children: [
      {
        path: "/dataSync",
        iconCls: "fa fa-random", // 图标样式class
        name: "",
        component: DataSync,
        children: []
      }
    ]
  },
]

export default new Router({
  routes: defaultRouter
})
export { defaultRouter, addrouters }