import type { RouteRecordRaw } from 'vue-router'
import user_c from './user/index.vue'
import mailbox_c from './mailbox/index.vue'
import setting_c from './setting/index.vue'
import homeHistory_c from './homework/history/index.vue'
import homeReports_c from './homework/reports/index.vue'
import homeWork_c from './homework/index.vue'
import homeWorkWrong_c from './homework/wrong/index.vue'
import homeWorkWrongQuestion_c from './homework/wrongQuestion/index.vue'
import homeWorkStatistics_c from './homework/statistics/index.vue'
const routes: RouteRecordRaw = {
  name: 'system',
  path: 'system',
  children: [
    {
      name: 'mailbox',
      path: 'mailbox',
      // component: () => import('./mailbox/index.vue'),
      component: mailbox_c,
      meta: { title: '信箱' },
    },
    {
      name: 'activity',
      path: 'activity',
      component: () => import('./activity/index.vue'),
      meta: { title: '活动' },
    },
    {
      name: 'announcement',
      path: 'announcement',
      component: () => import('./announcement/index.vue'),
      meta: { title: '公告' },
    },
    {
      name: 'setting',
      path: 'setting',
      // component: () => import('./setting/index.vue'),
      component: setting_c,
      meta: { title: '设置' },
    },
    {
      path: 'homeWork',
      children: [
        {
          name: 'HomeWorkHistory',
          path: 'history',
          component: homeHistory_c,
          meta: { title: '作业记录' },
        },
        {
          name: 'HomeWorkReports',
          path: 'reports/:id',
          component: homeReports_c,
          meta: { title: '作业报告' },
        },
        {
          name: 'HomeWork',
          path: '',
          component: homeWork_c,
          meta: { title: '未完成作业' },
        },
        {
          name: 'HomeWorkWrong',
          path: 'wrong',
          component: homeWorkWrong_c,
          meta: { title: '错题本' },
          beforeEnter: (to, from) => {
            if (from.name === 'HomeWork') {
              to.meta.subjectId = to.query.subjectId
            }
          },
        },
        {
          name: 'HomeWorkWrongQuestion',
          path: 'wrongQuestion',
          component: homeWorkWrongQuestion_c,
          meta: { title: '错题本' },
        },
        {
          name: 'HomeWorkStatistics',
          path: 'statistics',
          component: homeWorkStatistics_c,
          meta: { title: '统计分析' },
        },
        {
          name: 'HomeWorkTemporary',
          path: 'temporary',
          component: () => import('./homework/temporary/index.vue'),
          meta: { title: '临时作业' },
        },
        {
          name: 'HomeWorkSingleTemporary',
          path: 'temporaryHomeWork/:id',
          component: () => import('./homework/temporary/singleDetail.vue'),
          meta: { title: '临时作业' },
        },
      ],
    },
    {
      path: 'user',
      children: [
        {
          name: 'user',
          path: '',
          // component: () => import('./user/index.vue'),
          component: user_c,
          meta: { title: '基本信息' },
        },
        {
          name: 'OrderRecord',
          path: 'orderRecord',
          component: () => import('./user/orderRecord.vue'),
          meta: { title: '开通记录' },
        },
      ],
    },
  ],
}

export default routes
