import Main from "@/views/Main.vue";

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
  path: "/login",
  name: "login",
  meta: {
    title: "机考数据中心 - 登录",
  },
  component: (resolve) => {
    require(["@/views/login.vue"], resolve);
  },
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
  path: "/",
  name: "otherRouter",
  redirect: "/home",
  component: Main,
  children: [
    {
      path: "home",
      title: "主页",
      name: "home",
      component: (resolve) => {
        require(["@/views/home/home.vue"], resolve);
      },
    },
    // { path: 'ownspace', title: '个人中心', name: 'ownspace_index', component: resolve => { require(['@/views/own-space/own-space.vue'], resolve); } },
    {
      path: "examplan/add",
      title: "新建考试任务",
      name: "exam_plan_add",
      component: (resolve) => {
        require(["@/views/exam/exam-plan-add.vue"], resolve);
      },
    },
    {
      path: "examplan/edit/:id",
      title: "编辑考试任务",
      name: "exam_plan_edit",
      component: (resolve) => {
        require(["@/views/exam/exam-plan-edit.vue"], resolve);
      },
    },
    {
      path: "examplan/room",
      title: "查看考场数据",
      name: "exam_plan_room_view",
      component: (resolve) => {
        require(["@/views/exam/exam-plan-room-view.vue"], resolve);
      },
    },
    {
      path: "examplan/student",
      title: "查看考生数据",
      name: "exam_plan_student_view",
      component: (resolve) => {
        require(["@/views/exam/exam-plan-student-view.vue"], resolve);
      },
    },
  ],
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
  {
    path: "/examplan",
    icon: "ivu-icon ivu-icon-ios-desktop",
    name: "examplan",
    title: "机考",
    component: Main,
    children: [
      {
        path: "",
        icon: "fa fa-tasks",
        title: "考试任务管理",
        name: "exam_plan_index",
        component: (resolve) => {
          require(["@/views/exam/exam-plan.vue"], resolve);
        },
      },
      {
        path: "/kw/charts",
        icon: "fa fa-download",
        title: "考务下载监控",
        name: "exam_plan_kw_progress",
        component: (resolve) => {
          require(["@/views/exam/exam-plan-kw-progress.vue"], resolve);
        },
      },
      {
        path: "/paper/uncoiling",
        icon: "fa fa-unlock-alt",
        title: "开卷管理",
        name: "exam_plan_paper_uncoiling",
        component: (resolve) => {
          require(["@/views/exam/exam-plan-paper-uncoiling.vue"], resolve);
        },
      },
      {
        path: "/room/uncoiling",
        icon: "fa fa-folder-open",
        title: "开卷监控",
        name: "exam_plan_room_uncoiling",
        component: (resolve) => {
          require(["@/views/exam/exam-plan-room-uncoiling.vue"], resolve);
        },
      },
      {
        path: "progress",
        icon: "fa fa-folder-open",
        title: "考试进度查询",
        name: "exam_plan_progress",
        component: (resolve) => {
          require(["@/views/exam/exam-plan-progress.vue"], resolve);
        },
      },
      {
        path: "normal",
        icon: "fa fa-pie-chart",
        title: "通用机考汇总",
        name: "exam_plan_kj_hz",
        component: (resolve) => {
          require(["@/views/exam/exam-plan-kj-hz-normal.vue"], resolve);
        },
      },
      {
        path: "solfege",
        icon: "fa fa-pie-chart",
        title: "视唱机考汇总",
        name: "exam_plan_kj_hz_solfege",
        component: (resolve) => {
          require(["@/views/exam/exam-plan-kj-hz-solfege.vue"], resolve);
        },
      },
      {
        path: "/jkd-rz",
        icon: "fa fa-pie-chart",
        title: "监考端日志管理",
        name: "exam_plan_jkd_rz",
        component: (resolve) => {
          require(["@/views/exam/exam-plan-jkd-rz.vue"], resolve);
        },
      },
      {
        path: "/jkd-sj",
        icon: "fa fa-pie-chart",
        title: "监考端数据管理",
        name: "exam_plan_jkd_sj",
        component: (resolve) => {
          require(["@/views/exam/exam-plan-jkd-sj.vue"], resolve);
        },
      },
      // { path: 'solfege',icon:'fa fa-pie-chart', title: '视唱机考汇总', name: 'exam_plan_kj_hz_solfege', component: resolve => { require(['@/views/exam/exam-plan-kj-hz-solfege.vue'], resolve); } },
      {
        path: "/kj/charts",
        icon: "fa fa-bar-chart",
        title: "查询统计",
        name: "exam_plan_kw_hz",
        component: (resolve) => {
          require(["@/views/exam/exam-plan-kw-hz.vue"], resolve);
        },
      },
      {
        path: "/kw/task",
        icon: "fa fa-bar-chart",
        title: "考试同步管理",
        name: "exam_kw_task",
        component: (resolve) => {
          require(["@/views/exam/exam-task-manager.vue"], resolve);
        },
      },
    ],
  },
  {
    path: "/user",
    icon: "ivu-icon ivu-icon-md-person",
    name: "user",
    title: "用户",
    component: Main,
    children: [
      {
        path: "manage",
        role: "SUPER_ADMIN",
        icon: "fa fa-user-circle",
        title: "用户管理",
        name: "user_manage",
        component: (resolve) => {
          require(["@/views/exam/exam-user-manager.vue"], resolve);
        },
      },
      {
        path: "/personal",
        icon: "fa fa-cog",
        title: "修改密码",
        name: "rest_password",
        component: (resolve) => {
          require(["@/views/exam/rest-password.vue"], resolve);
        },
      },
    ],
  },
  {
    path: "/config",
    icon: "ivu-icon ivu-icon-md-settings",
    name: "config",
    title: "配置中心",
    component: Main,
    children: [
      {
        path: "/auth",
        icon: "fa fa-cog",
        title: "授权配置",
        name: "auth_set",
        role: "SUPER_ADMIN",
        component: (resolve) => {
          require(["@/views/exam/auth-set.vue"], resolve);
        },
      },
      {
        path: "/school-manage",
        icon: "fa fa-cog",
        title: "学校管理",
        name: "school_manange",
        role: "SUPER_ADMIN",
        component: (resolve) => {
          require(["@/views/exam/school-manage.vue"], resolve);
        },
      },
    ],
  },
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [loginRouter, otherRouter, ...appRouter];
