text: import Vue from 'vue'
  import VueRouter from 'vue-router'
  import Main from '../views/Main.vue'
  import Login from '../views/Login.vue'
  
  import ArticleEdit from '../views/ArticleEdit.vue'
  import ArticleList from '../views/ArticleList.vue'
  
  import TagEdit from '../views/TagEdit.vue'
  import TagList from '../views/TagList.vue'
  
  import AdminUserEdit from '../views/AdminUserEdit.vue'
  import AdminUserList from '../views/AdminUserList.vue'
  
  Vue.use(VueRouter)
  
  const routes = [
    { path: '/login', component: Login, meta: { isPublic: true } },
    {
      path: '/',
      component: Main,
      children: [
        { path: '/', component: ArticleList },
        { path: '/articles/create', component: ArticleEdit },
        { path: '/articles/edit/:id', component: ArticleEdit, props: true },
  
        { path: '/tags/list', component: TagList },
        { path: '/tags/create', component: TagEdit },
        { path: '/tags/edit/:id', component: TagEdit, props: true },
  
        { path: '/admin_users/list', component: AdminUserList },
        { path: '/admin_users/create', component: AdminUserEdit },
        { path: '/admin_users/edit/:id', component: AdminUserEdit, props: true }
      ]
    }
  ]
  
  const router = new VueRouter({
    routes
  })
  
  router.beforeEach((to, from, next) => {
    if (!to.meta.isPublic && !localStorage.token) {
      return next('/login')
    }
    next()
  })
  
  export default router
  