
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

import role from './modules/role'
import article from './modules/article'
import member from './modules/member'
import org from './modules/org'
import marketing_tool from './modules/marketing_tool'
import system from './modules/system'

/** note: submenu only apppear when children.length>=1
 *   detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length

// 详见 xt_permission.xt_filterAsyncRouter 函数的逻辑
is_menu: false               加载路由时验证用的(即该路由是否要在侧边栏展示，需要展示的即需要)，为 false 时表示该路由不需要进行权限验证

*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)

    // 详见 xt_permission.xt_filterAsyncRouter 函数的逻辑
    is_menu: false               加载路由时验证用的，为 false 时表示该路由不需要进行权限验证
    hidden: false                加载路由时验证用的，is_menu 为true时才有作用，为 true 时表示该路由需要进行权限验证
  }
**/
var _constant_router_map = [{
  path: '/token/verify',
  component: () => import('@/scrm_pages/index/verify_token'),
  hidden: true
},
{
  path: '/404',
  component: () => import('@/views/errorPage/404'),
  hidden: true
},
{
  path: '/401',
  component: () => import('@/views/errorPage/401'),
  hidden: true
},
{
  path: '',
  component: Layout,
  redirect: '/home',
  children: [{
    path: '/home',
    component: () => import('@/scrm_pages/home/index'),
    name: 'home',
    meta: {
      title: 'home',
      icon: 'dashboard',
      noCache: true
    }
  }]
}
  // service
]

var _asy_router_map = [
  member,
  article,
  marketing_tool,
  org,
  role,
  system
]

var is_asy_router = process.env.NODE_ENV === 'production' // true; 设置为 true 强制进行路由验证
if (!is_asy_router) {
  _constant_router_map = _constant_router_map.concat(_asy_router_map)
  _asy_router_map = []
} else {

}

export const xt_constantRouterMap = _constant_router_map
export const xt_asyncRouterMap = _asy_router_map

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: xt_constantRouterMap
})
