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.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: 'score',
        name: 'score',
        component: () => import('@/views/exam/score.vue')
      },
      {
        path: 'examList',
        name: 'examList',
        component: () => import('@/views/exam/examList.vue')
      },
    ]
  },
  {
    path: '/:pathMatch(.*)*', // 捕获所有未匹配路径
    name: 'NotFound',
    component: () => import('../views/login/login.vue') // 未匹配到路由跳转到登录页面
  }
]

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

export default router