import Vue from 'vue'
import Router from 'vue-router'
import Main from '@/components/Main.vue'
import Login from '@/components/Login/Login.vue'
import Register from '@/components/Register/Register.vue'
import ExamCenter from '@/components/ExamCenter/ExamCenter.vue'
import ExamStart from '@/components/ExamStart/ExamStart.vue'
import ExamHistory from '@/components/ExamHistory/ExamHistory.vue'

Vue.use(Router)

const router =  new Router({
  routes: [
    {
      path: '/login',
      name: 'Login',
      component: Login,
      meta: {isPublic: true}
    },
    { path: '/main',
      name: 'main',
      component: Main,
    },
    {
      path: '/',
      name: 'ExamCenter',
      component: ExamCenter
    },
    {
      path: '/register',
      name: 'Register',
      component: Register,
    },
    {
      path: '/exam/center',
      name: 'ExamCenter',
      component: ExamCenter
    },
    {
      path: '/exam/start/:paperId',
      name: 'ExamStart',
      component: ExamStart,
    },
    {
      path: '/exam/history',
      name: 'ExamHistory',
      component: ExamHistory
    }
  ]
})

// //路由守卫
// router.beforeEach((to, from ,next) => {
//   if (!to.meta.isPublic && !sessionStorage.getItem("userInfo")) {
//     return next('/login')
//   }
//   next()
// })

export default router
