import Vue from 'vue';
import VueRouter from 'vue-router';
import gurad from './guard';
import selfShop from './module/selfShop';
import platmanag from './module/platmanag';
import platActivi from './module/platActivi';
import platfinance from './module/platfinance';
import platSettings from './module/platSettings';
import zr from './module/zr';
import dev from './module/dev';
import account from './module/account';
import platGroup from './module/platGroup';
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,
      ...selfShop,
      ...platActivi,
      ...platSettings,
      ...platmanag,
      ...platfinance,
      ...platGroup,
      ...zr,
      ...account,
    ],
  },
];

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