import App from '../app.vue'
import container from '../components/layout/container.vue'

export default [
  { path: '/', redirect: window.document.documentElement.clientWidth > 799 ? '/app/my-learn/course' : '/mobile/list' },
  {
    path: '/login',
    redirect: '/login/index',
    component: () => import('../../components/login/login.vue'),
    children: [
      {
        path: 'index',
        name: 'normalLogin',
        component: () => import('../../components/login/normal/normal.vue'),
        props: (route) => ({ query: route.query, params: route.params })
      },
      {
        path: 'code',
        name: 'codeLogin',
        component: () => import('../../components/login/code/code.vue'),
        props: (route) => ({ query: route.query, params: route.params })
      },
      {
        path: 'forget',
        name: 'forgetPwd',
        component: () => import('../../components/login/forget/forget.vue'),
        props: (route) => ({ query: route.query, params: route.params })
      }
    ]
  },
  /* App 内登录页面未找到时 - 指向 */
  { path: '/login/*', redirect: '/login/index' },
  {
    path: '/app',
    redirect: '/app/error/404',
    component: App,
    children: [
      { path: 'error/404', component: () => import('../components/error/404.vue') },
      {
        path: 'my-learn',
        redirect: 'error/404',
        component: container,
        children: [
          { path: 'course', component: () => import('../pages/myLearn/course.vue') },
          { path: 'course-detail/:sid/:cid', component: () => import('../pages/myLearn/courseDetail.vue'), props: true },
          { path: 'discuss-detail/:sid/:cid/:id', component: () => import('../pages/myLearn/discussDetail.vue'), props: true },
          { path: 'course-all', component: () => import('../pages/myLearn/courseAll.vue') },
          { path: 'discussion', component: () => import('../pages/myLearn/discussion.vue') },
          { path: 'report-list', component: () => import('../pages/myLearn/reportList.vue') },
          { path: 'report-active-list', component: () => import('../pages/myLearn/reportActiveList.vue') },
          { path: 'report-list-all/:rid', component: () => import('../pages/myLearn/reportListAll.vue'), props: true },
          { path: 'report-add/:rid', component: () => import('../pages/myLearn/reportAdd.vue'), props: true },
          { path: 'report-submit/:rid/:reid', component: () => import('../pages/myLearn/reportSubmit.vue'), props: true }
        ]
      },
      {
        path: 'my-grade',
        redirect: 'error/404',
        component: container,
        children: [
          { path: 'credit', component: () => import('../pages/myGrade/credit.vue') },
          { path: 'rebuild', component: () => import('../pages/myGrade/rebuild.vue') },
          { path: 'message', component: () => import('../pages/myGrade/message.vue') }
        ]
      },
      {
        path: 'my-grade',
        redirect: 'error/404',
        component: container,
        children: [
          { path: 'credit', component: () => import('../pages/myGrade/credit.vue') },
          { path: 'rebuild', component: () => import('../pages/myGrade/rebuild.vue') },
          { path: 'message', component: () => import('../pages/myGrade/message.vue') }
        ]
      },
      {
        path: 'account',
        redirect: 'error/404',
        component: container,
        children: [
          { path: 'set-pwd', component: () => import('../pages/account/setPwd.vue') },
          { path: 'update-pic', component: () => import('../pages/account/updatePic.vue') },
          { path: 'feedbackList', component: () => import('../pages/account/feedbackList.vue') },
          { path: 'feedbackCreate', component: () => import('../pages/account/feedbackCreate.vue') }
        ]
      },
      {
        path: 'service-hall',
        redirect: 'error/404',
        component: container,
        children: [
          { path: 'hall', component: () => import('../pages/serviceHall/hall.vue') }
        ]
      }
    ]
  },
  /* App 内未找到页面时 - 指向 */
  { path: '/app/*', redirect: '/app/error/404' },
  {
    path: '/player/:sid/:cid',
    redirect: '/player/0/0/error/404',
    component: () => import('../../components/player/index.vue'),
    props: true,
    children: [
      { path: 'error/404', component: () => import('../components/error/404.vue') },
      {
        path: 'chapter-video/:id/:videoType',
        name: 'chapterVideo',
        component: () => import('../../components/player/chapterVideo/chapterVideo.vue'),
        props: true
      },
      {
        path: 'chapter-exam/:id',
        name: 'chapterExam',
        component: () => import('../../components/player/chapterExam/chapterExam.vue'),
        props: true
      },
      {
        path: 'chapter-read/:id',
        name: 'chapterRead',
        component: () => import('../../components/player/chapterRead/chapterRead.vue'),
        props: true
      },
      {
        path: 'chapter-work/:id',
        name: 'chapterWork',
        component: () => import('../../components/player/chapterWork/chapterWork.vue'),
        props: true
      },
      {
        path: 'course-info/:id',
        name: 'courseInfo',
        component: () => import('../../components/player/courseInfo/courseInfo.vue'),
        props: true
      },
      {
        path: 'course-work/:id',
        name: 'courseWork',
        component: () => import('../../components/player/courseWork/courseWork.vue'),
        props: true
      },
      {
        path: 'exam/:id',
        name: 'exam',
        component: () => import('../../components/player/exam/exam.vue'),
        props: true
      },
      {
        path: 'live/:id',
        name: 'live',
        component: () => import('../../components/player/live/live.vue'),
        props: true
      }
    ]
  },
  /* App 内登录页面未找到时 - 指向 */
  { path: '/player/*', redirect: '/player/0/0/error/404' },
  {
    path: '/survey/:sid/:cid',
    name: 'survey',
    component: () => import('../../components/survey/survey.vue'),
    props: true
  },
  /* survey 内未找到页面时 - 指向 */
  { path: '/survey/*', redirect: '/learn-error/learn-error' },
  {
    path: '/survey-phone/:sid/:cid',
    name: 'survey-phone',
    component: () => import('../../components/survey/surveyPhone.vue'),
    props: true
  },
  /* mobile 移动端 - 指向 */
  {
    path: '/mobile',
    redirect: '/mobile/0/0/error/404',
    component: () => import('../pages/mobile/index.vue'),
    props: true,
    children: [
      { path: 'error/404', component: () => import('../components/error/404.vue') },
      {
        path: 'list',
        name: 'list',
        component: () => import('../pages/mobile/list.vue'),
        props: true
      },
      {
        path: 'help/student',
        name: 'studentHelp',
        component: () => import('../pages/mobile/studentHelp.vue')
      },
      {
        path: 'help/teacher',
        name: 'teacherHelp',
        component: () => import('../pages/mobile/teacherHelp.vue')
      }
    ]
  },
  /* survey-phone 内未找到页面时 - 指向 */
  { path: '/survey-phone/*', redirect: '/learn-error/learn-error' },
  /* 静态测试页面 */
  { path: '/static/index', component: () => import('../pages/static/index.vue') },
  /* 如果所有页面都没找到 - 指向 */
  { path: '*', component: () => import('../components/error/404.vue') }
]
