import Vue from 'vue'
import Router from 'vue-router'
/* Layout */
import Layout from '@/layout'

// 解决冗余导航报错
const originalPush = Router.prototype.push

Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)

/**
 * Note: 路由配置项
 *
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true               // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'             // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * meta : {
    noCache: true                // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'             // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
  }
 */

// 公共路由
export const constantRoutes = [{
  path: '/redirect',
  component: Layout,
  hidden: true,
  children: [{
    path: '/redirect/:path(.*)',
    component: (resolve) => require(['@/views/redirect'], resolve)
  }]
},
  {
    path: '/login',
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/error/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/error/401'], resolve),
    hidden: true
  },

  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [{
      path: 'index',
      component: (resolve) => require(['@/views/index'], resolve),
      name: '首页',
      meta: {
        title: '首页',
        icon: 'dashboard',
        noCache: true,
        affix: true
      }
    }]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [{
      path: 'profile',
      component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
      name: 'Profile',
      meta: {
        title: '个人中心',
        icon: 'user'
      }
    }, {
      path: 'record',
      component: (resolve) => require(['@/views/system/user/profile/components/record'], resolve),
      name: 'record',
      meta: {
        title: '学生使用详情',
        icon: 'user'
      }
    }, {
      path: 'statistics',
      component: (resolve) => require(['@/views/system/user/profile/statistics'], resolve),
      name: 'SysStatistics',
      meta: {
        title: '学生使用详情',
        icon: 'user'
      }
    }, {
      path: 'UserStatisticsInfo',
      component: (resolve) => require(['@/views/system/user/profile/components/UserStatisticsInfo'], resolve),
      name: 'UserStatisticsInfo',
      meta: {
        title: '学生使用详情',
        icon: 'user'
      }
    },
      {
        path: 'PersonInfo',
        component: (resolve) => require(['@/views/system/user/profile/components/PersonInfo'], resolve),
        name: 'PersonInfo',
        meta: {
          title: '学生使用详情-具体',
          icon: 'user'
        }
      }
    ]
  },
  {
    path: '/dict',
    component: Layout,
    hidden: true,
    children: [{
      path: 'type/data/:dictId(\\d+)',
      component: (resolve) => require(['@/views/system/dict/data'], resolve),
      name: 'Data',
      meta: {
        title: '字典数据',
        icon: ''
      }
    }]
  },
  {
    path: '/job',
    component: Layout,
    hidden: true,
    children: [{
      path: 'log',
      component: (resolve) => require(['@/views/monitor/job/log'], resolve),
      name: 'JobLog',
      meta: {
        title: '调度日志'
      }
    }]
  },
  {
    path: '/gen',
    component: Layout,
    hidden: true,
    children: [{
      path: 'edit/:tableId(\\d+)',
      component: (resolve) => require(['@/views/tool/gen/editTable'], resolve),
      name: 'GenEdit',
      meta: {
        title: '修改生成配置'
      }
    }]
  },
  {
    path: '/idc',
    component: Layout,
    hidden: true,
    children: [{
      path: 'EvaluationDatabase/detailList',
      component: (resolve) => require(['@/views/idc/EvaluationDatabase/detailList'], resolve),
      name: 'EvaluationDatabaseDetail',
      meta: {
        title: '详情'
      }
    },
      {
        path: 'EvaluationDatabase/list',
        component: (resolve) => require(['@/views/idc/EvaluationDatabase/list'], resolve),
        name: 'EvaluationDatabaseList',
        meta: {
          title: '选择班级'
        }
      },
      {
        path: 'EvaluationDatabase/statistics',
        component: (resolve) => require(['@/views/idc/EvaluationDatabase/statistics'], resolve),
        name: 'EvaluationStatistics',
        meta: {
          title: '详情'
        }
      },
      {
        path: 'reviewHistory/userList',
        component: (resolve) => require(['@/views/idc/reviewHistory/userList'], resolve),
        name: 'reviewHistoryUserList',
        meta: {
          title: '详情'
        }
      },
      {
        path: 'reviewHistory/classList',
        component: (resolve) => require(['@/views/idc/reviewHistory/classList'], resolve),
        name: 'reviewHistoryClassList',
        meta: {
          title: '详情'
        }
      },
      {
        path: 'mistakesOnce/summary',
        component: (resolve) => require(['@/views/idc/mistakesOnce/summary'], resolve),
        name: 'mistakesOnceSummary',
        meta: {
          title: '汇总'
        }
      },
      {
        path: 'mistakesOnce/detail',
        component: (resolve) => require(['@/views/idc/mistakesOnce/detail'], resolve),
        name: 'mistakesOnceDetail',
        meta: {
          title: '详情'
        }
      },
      {
        path: 'mistakesOnce/list',
        component: (resolve) => require(['@/views/idc/mistakesOnce/list'], resolve),
        name: 'mistakesOnceList',
        meta: {
          title: '选择班级'
        }
      },
      {
        path: 'rankingOnce/list',
        component: (resolve) => require(['@/views/idc/rankingOnce/list'], resolve),
        name: 'rankingOnceList',
        meta: {
          title: '选择班级'
        }
      },
      {
        path: 'mistakes/userList',
        component: (resolve) => require(['@/views/idc/mistakes/userList'], resolve),
        name: 'userList',
        meta: {
          title: '详情'
        }
      },
      {
        path: 'mistakes/detail',
        component: (resolve) => require(['@/views/idc/mistakes/detail'], resolve),
        name: 'mistakesDetail',
        meta: {
          title: '详情'
        }
      },
      {
        path: 'mistakes/aiPaper',
        component: (resolve) => require(['@/views/idc/mistakes/aiPaper'], resolve),
        name: 'mistakesAIPaper',
        meta: {
          title: 'ai匹配试题'
        }
      },
      {
        path: 'student/getUser',
        component: (resolve) => require(['@/views/idc/student/getUser'], resolve),
        name: 'getUser',
        meta: {
          title: '选择学生'
        }
      },
      {
        path: 'student/list',
        component: (resolve) => require(['@/views/idc/student/list'], resolve),
        name: 'studentList',
        meta: {
          title: '学生单次测评数据'
        }
      },
      {
        path: 'student/index',
        component: (resolve) => require(['@/views/idc/student/index'], resolve),
        name: 'studentIndex',
        meta: {
          title: '学生单次测评数据'
        }
      },
      {
        path: 'student/once',
        component: (resolve) => require(['@/views/idc/student/once'], resolve),
        name: 'studentOnce',
        meta: {
          title: '学生单次测评数据'
        }
      },
      {
        path: 'student/ranking',
        component: (resolve) => require(['@/views/idc/student/ranking'], resolve),
        name: 'studentRanking',
        meta: {
          title: '学生单次测评数据'
        }
      },
      {
        path: 'student/history',
        component: (resolve) => require(['@/views/idc/student/history'], resolve),
        name: 'studentHistory',
        meta: {
          title: '学生单次测评数据'
        }
      },
      {
        path: 'EvaluationDatabase/analysisList',
        component: (resolve) => require(['@/views/idc/EvaluationDatabase/analysisList'], resolve),
        name: 'analysisList',
        meta: {
          title: '学情分析'
        }
      },
      {
        path: 'class-manage/single',
        component: (resolve) => require(['@/views/idc/EvaluationDatabase/index'], resolve),
        name: 'classManageSingle',
        meta: {
          title: '班级单次测评统计'
        }
      },
      {
        path: 'class-manage/multiple',
        component: (resolve) => require(['@/views/idc/reviewHistory/index'], resolve),
        name: 'classManageMultiple',
        meta: {
          title: '班级多次测评统计'
        }
      },
      {
        path: 'class-manage/ranking',
        component: (resolve) => require(['@/views/idc/rankingOnce/index'], resolve),
        name: 'classManageRanking',
        meta: {
          title: '班级单次测评排名'
        }
      },
      {
        path: 'class-manage/wrong',
        component: (resolve) => require(['@/views/idc/mistakesOnce/index'], resolve),
        name: 'classManageWrong',
        meta: {
          title: '班级单次错题排名'
        }
      }
    ]
  },
  {
    path: '/evaluating',
    component: Layout,
    hidden: true,
    children: [{
      path: '/evaluating/answer',
      component: (resolve) => require(['@/views/evaluating/answer'], resolve),
      name: 'answer',
      meta: {
        title: '做题'
      }
    },
      {
        path: '/accurateTeaching/personalResources/add',
        component: (resolve) => require(['@/views/accurateTeaching/library/addLibrary'], resolve),
        name: 'addLibrary',
        meta: {
          title: '上传课件'
        }

      },
      {
        path: '/accurateTeaching/evaluating/inspection/class',
        component: (resolve) => require(['@/views/evaluating/inspectionClass'], resolve),
        name: 'inspectionClass',
        meta: {
          title: '选择班级'
        }

      },
      {
        path: '/accurateTeaching/evaluating/inspection/student',
        component: (resolve) => require(['@/views/evaluating/inspectionStudent'], resolve),
        name: 'inspectionStudent',
        meta: {
          title: '选择学生'
        }
      }
    ]
  },
  {
    path: '/competition',
    component: Layout,
    hidden: true,
    children: [{
      path: '/competition/detail',
      component: (resolve) => require(['@/views/competition/detail'], resolve),
      name: 'detail',
      meta: {
        title: '报名阶段'
      }

    }]
  },
  {
    path: '/competitioninfo',
    component: Layout,
    hidden: true,
    children: [{
      path: '/competitioninfo/index',
      component: (resolve) => require(['@/views/competitioninfo/index'], resolve),
      name: 'competitioninfoIndex',
      meta: {
        title: '竞赛信息'
      }
    },
      {
        path: '/video_course/video-course',
        // component: Layout,
        hidden: true,
        component: (resolve) => require(['@/views/videocourse/video_course'], resolve),
        meta: {
          title: '视频课程首页'
        }
      },
      {
        path: '/video_course/detail',
        // component: Layout,
        hidden: true,
        component: (resolve) => require(['@/views/videocourse/VideoDetail'], resolve),
        meta: {
          title: '课程详情页'
        }
      },
      {
        path: '/question-center/main',
        // component: Layout,
        hidden: true,
        component: (resolve) => require(['@/views/questioncenter/main'], resolve),
        meta: {
          title: '题库中心首页'
        }
      },
      {
        path: '/question-center/smartExercise/practice',
        // component: Layout,
        hidden: true,
        component: (resolve) => require(['@/views/questioncenter/practice'], resolve),
        meta: {
          title: '题库中心-智能练习-试卷'
        }
      },
      {
        path: '/question-center/smartExercise/answerDetailas',
        // component: Layout,
        hidden: true,
        component: (resolve) => require(['@/views/questioncenter/AnswerDetails'], resolve),
        meta: {
          title: '题库中心-智能练习-试卷结果'
        }
      },
      {
        path: '/question-center/learningAssitant',
        // component: Layout,
        hidden: true,
        component: (resolve) => require(['@/views/questioncenter/LearnHelper'], resolve),
        meta: {
          title: '题库中心'
        }
      },
      {
        path: '/question-center/smartExercise',
        // component: Layout,
        hidden: true,
        component: (resolve) => require(['@/views/questioncenter/smart'], resolve),
        meta: {
          title: '题库中心智能练习'
        }
      },
      {
        path: '/question-center/bestPaper',
        // component: Layout,
        hidden: true,
        component: (resolve) => require(['@/views/questioncenter/bestpaper'], resolve),
        meta: {
          title: '题库中心精品试卷'
        }
      },
      {
        path: '/question-center/bestPaper/preview',
        // component: Layout,
        hidden: true,
        component: (resolve) => require(['@/views/questioncenter/PaperPreview'], resolve),
        meta: {
          title: '题库中心精品试卷-预览'
        }
      },
      {
        path: '/question-center/generatingPaperCenter',
        // component: Layout,
        hidden: true,
        component: (resolve) => require(['@/views/questioncenter/generating'], resolve),
        meta: {
          title: '题库中心组卷中心'
        }
      },
      {
        path: '/question-center/generatingPaperCenter/paper',
        // component: Layout,
        hidden: true,
        component: (resolve) => require(['@/views/questioncenter/paper'], resolve),
        meta: {
          title: '组卷中心生成试卷'
        }
      }
    ]
  },
  {
    path: '/career',
    component: Layout,
    hidden: true,
    children: [{
      path: '/career/plan/detail',
      component: (resolve) => require(['@/views/career/plan/detail'], resolve),
      name: 'careerDetail',
      meta: {
        title: '播放视频'
      }
    },
      {
        path: '/career/gkmc/index',
        component: (resolve) => require(['@/views/career/zhiyuan/gkmc'], resolve),
        name: 'gkmc',
        meta: {
          title: '高考名词'
        }
      },
      {
        path: '/career/gkmc/detail',
        component: (resolve) => require(['@/views/career/zhiyuan/gkmcDetail'], resolve),
        name: 'gkmcdetail',
        meta: {
          title: '高考名词详情'
        }
      },
      {
        path: '/career/batch',
        component: (resolve) => require(['@/views/career/zhiyuan/batch'], resolve),
        name: 'batch',
        meta: {
          title: '批次控制线'
        }
      },
      {
        path: '/career/yfyd',
        component: (resolve) => require(['@/views/career/zhiyuan/yfyd'], resolve),
        name: 'yfyd',
        meta: {
          title: '一分一段'
        }
      },
      {
        path: '/career/zhiyuanSimulateOne',
        component: (resolve) => require(['@/views/career/zhiyuan/zhiyuanSimulateOne'], resolve),
        name: 'zhiyuanSimulateOne',
        meta: {
          title: '投档线'
        }
      },
      {
        path: '/career/ShiftLine',
        component: (resolve) => require(['@/views/career/zhiyuan/ShiftLine'], resolve),
        name: 'ShiftLine',
        meta: {
          title: '投档线'
        }
      },
      {
        path: '/career/SimulatedVolunteer',
        component: (resolve) => require(['@/views/career/zhiyuan/SimulatedVolunteer'], resolve),
        name: 'SimulatedVolunteer',
        meta: {
          title: '模拟志愿'
        }
      },
      {
        path: '/career/VolunteerList',
        component: (resolve) => require(['@/views/career/components/VolunteerList'], resolve),
        name: 'VolunteerList',
        meta: {
          title: '模拟志愿-填报记录'
        }
      },
      {
        path: '/career/RecordDetail',
        component: (resolve) => require(['@/views/career/components/RecordDetail'], resolve),
        name: 'RecordDetail',
        meta: {
          title: '模拟志愿-记录详情'
        }
      },
      {
        path: '/career/plan/CareerEva',
        component: (resolve) => require(['@/views/career/plan/CareerEva'], resolve),
        name: 'CareerEva',
        meta: {
          title: '生涯评测'
        }
      },
      {
        path: '/career/plan/CareerEvaDetail',
        component: (resolve) => require(['@/views/career/plan/CareerEvaDetail'], resolve),
        name: 'CareerEvaDetail',
        meta: {
          title: '生涯评测-职业兴趣测评'
        }
      },
      {
        path: '/career/components/CareerHollandReportList',
        component: (resolve) => require(['@/views/career/components/CareerHollandReportList'], resolve),
        name: 'CareerHollandReportList',
        meta: {
          title: '职业兴趣测评-评测列表'
        }
      },
      {
        path: '/career/components/CareerMbtiReportList',
        component: (resolve) => require(['@/views/career/components/CareerMbtiReportList'], resolve),
        name: 'CareerMbtiReportList',
        meta: {
          title: '职业性格测评-评测列表'
        }
      },
      {
        path: '/career/plan/ProfessLib',
        component: (resolve) => require(['@/views/career/plan/new-profess-lib'], resolve),
        name: 'ProfessLib',
        meta: {
          title: '专业库'
        }
      },
      {
        path: '/career/plan/ProfessLibDetail',
        component: (resolve) => require(['@/views/career/plan/new-profess-detail'], resolve),
        name: 'ProfessLibDetail',
        meta: {
          title: '专业库详情'
        }
      },
      {
        path: '/career/subject/index',
        component: (resolve) => require(['@/views/career/subject/index'], resolve),
        name: 'Subject',
        meta: {
          title: '选科查询',
          isWideScreen: true
        }
      },
      {
        path: '/career/subject/majorChoice',
        component: (resolve) => require(['@/views/career/subject/majorChoice'], resolve),
        name: 'MajorChoice',
        meta: {
          title: '由专业选科目'
        }
      },
      {
        path: '/career/subject/myChoice',
        component: (resolve) => require(['@/views/career/subject/myChoice'], resolve),
        name: 'MyChoice',
        meta: {
          title: '我的选科方案'
        }
      },
      {
        path: '/career/subject/subjectChoice',
        component: (resolve) => require(['@/views/career/subject/choose-subject.vue'], resolve),
        name: 'SubjectChoice',
        meta: {
          title: '由科目选专业'
        }
      },
      {
        path: '/career/plan/UniversitiesColleges',
        component: (resolve) => require(['@/views/career/plan/UniversitiesColleges'], resolve),
        name: 'UniversitiesColleges',
        meta: {
          title: '生涯评测-院校库'
        }
      },
      {
        path: '/career/components/UniversityDetail',
        component: (resolve) => require(['@/views/career/components//UniversityDetail'], resolve),
        name: 'UniversityDetail',
        meta: {
          title: '生涯评测-院校详情'
        }
      },
      {
        path: '/career/zhiyuan/index',
        // component: (resolve) => require(['@/views/career/zhiyuan/index'], resolve),
        component: (resolve) => require(['@/views/career/zhiyuan/SimulatedVolunteer'], resolve),
        name: 'FillIn',
        meta: {
          title: '志愿模拟填报'
        }
      },
      {
        path: '/career/subjectSign/index',
        component: (resolve) => require(['@/views/career/subjectSign/index'], resolve),
        name: 'SubjectSign',
        meta: {
          title: '选科报名'
        }
      },
      {
        path: '/career/vocation/index',
        component: (resolve) => require(['@/views/career/vocation/new-index'], resolve),
        name: 'Vocation',
        meta: {
          title: '职业库'
        }
      },
      {
        path: '/career/vocation/Detail',
        component: (resolve) => require(['@/views/career/vocation/new-detail'], resolve),
        name: 'jobDetail',
        meta: {
          title: '职业-详情'
        }
      }
    ]
  }, {
    path: '/elective',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/elective/test/index',
        component: (resolve) => require(['@/views/elective/test/index'], resolve),
        name: 'ElectiveTestIndex',
        meta: {
          title: '选科测评'
        }
      },
      {
        path: '/elective/test/elective-paper',
        component: (resolve) => require(['@/views/elective/test/elective-paper'], resolve),
        name: 'ElectivePaper',
        meta: {
          title: '选科测评试卷'
        }
      },
      {
        path: '/elective/test/elective-report',
        component: (resolve) => require(['@/views/elective/test/elective-report'], resolve),
        name: 'ElectiveReport',
        meta: {
          title: '选科测评报告'
        }
      },
      {
        path: '/elective/dispatch/detail',
        component: (resolve) => require(['@/views/elective/dispatch/detail'], resolve),
        name: 'DispatchDetail',
        meta: {
          title: '分班详情'
        }
      },
      {
        path: '/elective/generation/detail',
        component: (resolve) => require(['@/views/elective/generation/detail'], resolve),
        name: 'ElectiveGenerationDetail',
        meta: {
          title: '选科名单详情'
        }
      }
    ]
  }
]

export default new Router({
  mode: 'history', // 去掉url中的#
  // mode: 'hash', // 去掉url中的#
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})
