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

Vue.use(VueRouter)

const routes = [
  { path: '*', redirect: '/channel' },
  { path: '/', redirect: '/channel' },
  {
    name: 'login',
    path: '/login',
    component: () => import('@/views/Login.vue')
  },
  {
    name: 'channel',
    path: '/channel',
    component: () => import('@/views/Channel.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') }
    ]
  }
]

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

export default router
