import { createRouter, createWebHistory, createWebHashHistory  } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
import Layout from '@/views/layout/index.vue'

// 示例路由配置
const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: '',
    component: () => import('../views/login/login.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/login/login_other.vue')
  },
  //主页面
  {
    path: '/main',
    name: 'main',
    component: Layout,
    children: [
      {
        path: 'choice',
        name: 'school',
        component: () => import('@/views/choice/index.vue')
      },
      {
        path: 'fillblank',
        name: 'manager',
        component: () => import('@/views/fillblank/index.vue')
      },
      {
        path: 'essay',
        name: 'essay',
        component: () => import('@/views/essay/index.vue')
      }
    ]

  },
  //考试详情页面
  {
    path: '/exam',
    name: 'exam',
    component: () => import('@/views/exam/index.vue'),
    children:[
      {
        path: 'question',
        name: 'question',
        component: () => import('@/views/exam/question.vue')
      },
      {
        path: 'scanList',
        name: 'scanList',
        component: () => import('@/views/exam/scanList.vue')
      },
      {
        path: 'scanDetail',
        name: 'scanDetail',
        component: () => import('@/views/exam/scanDetail.vue')
      },
      {
        path: 'selectExamination',
        name: 'selectExamination',
        component: () => import('@/views/exam/selectExamination.vue')
      },
      {
        path: 'examList',
        name: 'examList',
        component: () => import('@/views/exam/examList.vue')
      },
      {
        path: 'analysis',
        name: 'analysis',
        component: () => import('@/views/analysis/index.vue'),
        redirect: 'score',   // 默认跳转到 score
        children:[
          {
            path: 'score',
            name: 'score',
            component: () => import('@/views/analysis/score.vue')
          },//成绩单
          {
            path: 'errorAnalysis',
            name: 'errorAnalysis',
            component: () => import('@/views/analysis/errorAnalysis.vue')
          },//错题分析
          {
            path: 'optionDetail',
            name: 'optionDetail',
            component: () => import('@/views/analysis/optionDetail.vue')
          },//选项明细
          {
            path: 'levelDistribution',
            name: 'levelDistribution',
            component: () => import('@/views/analysis/levelDistribution.vue')
          },//水平分布
          {
            path: 'classComparison',
            name: 'classComparison',
            component: () => import('@/views/analysis/classComparison.vue')
          },//班级对比
          {
            path: 'questionAnalysis',
            name: 'questionAnalysis',
            component: () => import('@/views/analysis/questionAnalysis.vue')
          },//小题分析
          {
            path: 'groupAnalysis',
            name: 'groupAnalysis',
            component: () => import('@/views/analysis/groupAnalysis.vue')
          },//分组分析
          {
            path: 'optionAnalysis',
            name: 'optionAnalysis',
            component: () => import('@/views/analysis/optionAnalysis.vue')
          },//选项分析
          {
            path: 'propositionAnalysis',
            name: 'propositionAnalysis',
            component: () => import('@/views/analysis/propositionAnalysis.vue')
          },//命题分析
        ]
      },
    ]
  },
  {
    path: '/:pathMatch(.*)*', // 捕获所有未匹配路径
    name: 'NotFound',
    component: () => import('../views/login/login.vue') // 未匹配到路由跳转到登录页面
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router