import Vue from 'vue';
import Router from 'vue-router';
import _import from './_import.js';
Vue.use(Router);

// const error403 = (r) => {
//   import('views/errorPage/403.vue').then((module) => {
//     r(module)
//   })
// };
// const error404 = (r) => {
//   import('views/errorPage/404.vue').then((module) => {
//     r(module)
//   })
// };
// const error500 = (r) => {
//   import('views/errorPage/500.vue').then((module) => {
//     r(module)
//   })
// };
const errorPage = r => {
  import('views/errorPage/index.vue').then(module => {
    r(module);
  });
};

export const constantRouterMap = [
  {
    path: '/',
    name: '/',
    redirect: 'home'
  },
  {
    path: '/login',
    name: '登录',
    component: _import('login', 'index')
  },
  {
    path: '/index',
    name: '首页',
    redirect: 'home',
    component: _import('index', 'index'),
    children: [
      {
        path: '/home',
        name: '首页',
        component: _import('index', 'home')
      },
      {
        path: '/noticeDetail',
        name: '公告详情',
        component: _import('index', 'noticeDetail')
      },
      {
        path: '/noticeList',
        name: '公告列表',
        component: _import('index', 'noticeList')
      }
    ]
  },
  {
    path: '/document',
    name: '文档中心',
    component: _import('document', 'index')
  },
  {
    path: '/403',
    name: '无权访问',
    component: errorPage
  },
  {
    path: '/404',
    name: 'error404',
    component: errorPage
  },
  {
    path: '/500',
    name: 'error500',
    component: errorPage
  },
  { path: '*', redirect: '/404', hidden: true }
];
export default new Router({
  // mode:'history',
  routes: constantRouterMap,
  scrollBehavior: () => ({ y: 0 })
});
