import { createRouter, RouteRecordRaw, createWebHistory, createWebHashHistory } from 'vue-router'
import { ERouterName } from '@/types/index'

// const router = createRouter({
//   history: createWebHistory(import.meta.env.BASE_URL),
//   routes: [
//     {
//       path: '/',
//       name: 'login',
//       component: () => import('../views/Login.vue'),
//     },
//     {
//       path: '/about',
//       name: 'about',
//       // route level code-splitting
//       // this generates a separate chunk (About.[hash].js) for this route
//       // which is lazy-loaded when the route is visited.
//       component: () => import('../views/AboutView.vue'),
//     },
//   ],
// })
const routes: Array<RouteRecordRaw> = [
  // {
  //   path: '/',
  //   redirect: '/' + ERouterName.LOGIN
  // },
  {
    path: '/',
    redirect: '/login',
  },
  {
    path: '/login',
    name: ERouterName.LOGIN,
    component: () => import('@/views/Login.vue')
  },
  {
    path: '/dronePilotList',
    name: ERouterName.DRONEPILOTLIST,
    component: () => import('@/views/DronePilotList.vue')
  },
  {
    path: '/dronePilotDetails',
    name: ERouterName.DRONEPILOTDETAILS,
    component: () => import('@/views/DronePilotDetails.vue')
  },
  {
    path: '/dronePilotShare',
    name: ERouterName.DRONEPILOTSHARE,
    component: () => import('@/views/DronePilotShare.vue')
  },
  {
    path: '/' + ERouterName.DRONE,
    name: ERouterName.DRONE,
    component: () => import('@/views/drone/index.vue')
  },
  {
    path: '/' + ERouterName.PILOT,
    name: ERouterName.PILOT,
    component: () => import('@/views/pilot/index.vue')
  },
]

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes
})

export default router
