import Vue from 'vue';
import VueRouter from 'vue-router';
import gurad from './guard';
import selfShop from './module/selfShop';
import system from './module/system';
import dev from './module/dev';
Vue.use(VueRouter);

const routes = [
  {
    path: '/login',
    name: 'login',
    meta: { title: '管理登录' },
    component: () => import('../views/login.vue'),
  },
  {
    path: '/',
    // 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(/* webpackChunkName: "frame" */ '@/layout/Home.vue'),
    children: [
      {
        path: '/',
        name: 'index',
        meta: { title: '首页' },
        component: () => import(/* webpackChunkName: "home" */ '@/views/index.vue'),
      },
      ...dev,
      ...system,
      ...selfShop,
    ],
  },
];

const router = new VueRouter({
  mode: 'history',
  base: process.env.VUE_APP_ROUTER,
  routes,
});
gurad(router);
export default router;
