import Vue from 'vue'
import Router from 'vue-router'

import routerBefore from '@/config/routerBefore.js'

import main from '@/components/main.vue'
import mainDefault from '@/views/index/components/default.vue'
// 登录
import login from '@/views/index/components/login.vue'

Vue.use(Router)

export const constantRouterMap = [{
  path: '/',
  meta: {
    'title': '登录'
  },
  component: login
},
{
  path: '/login',
  name: 'login',
  meta: {
    'title': '登录'
  },
  component: login
},
{
  path: '/main',
  name: 'main',
  component: main,
  redirect: {
    name: 'default'
  },
  meta: {
    'title': '首页'
  },
  children: [{
    path: 'default',
    name: 'default',
    meta: {
      'title': '首页'
    },
    component: mainDefault
  }]
}
];

const router = new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
});

export default router;

//
routerBefore(router);
