import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/components/Layout.vue'

Vue.use(VueRouter)

const routes = [
  { path: '*', redirect: '/' },
  { name: 'index', path: '/', component: () => import('@/views/Index.vue') },
  {
    name: 'login',
    path: '/login',
    component: () => import('@/views/Login.vue')
  },
  {
    path: '/list',
    component: Layout,
    children: [
      { name: 'list', path: '', component: () => import('@/views/List.vue') }
    ]
  },
  {
    path: '/create',
    component: Layout,
    children: [
      {
        name: 'create',
        path: '',
        component: () => import('@/views/Create.vue')
      }
    ]
  },
  {
    path: '/edit',
    component: Layout,
    children: [
      { name: 'edit', path: '', component: () => import('@/views/Edit.vue') }
    ]
  },
  {
    path: '/view',
    component: Layout,
    children: [
      { name: 'view', path: '', component: () => import('@/views/View.vue') }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
