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

const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

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

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

/**
 * 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
 *                                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 : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if fasle ,the page will no be cached(default is false)
  }
 **/
export const constantRouterMap = [
  { path: '/login', component: _import('login/index'), hidden: true },
  { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
  { path: '/404', component: _import('error/404'), hidden: true },
  { path: '/401', component: _import('error/401'), hidden: true },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [{
      path: 'dashboard',
      component: _import('dashboard/index'),
      name: 'dashboard',
      meta: { title: '首页', icon: 'dashboard', noCache: true }
    }]
  }
]

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

export const asyncRouterMap = [
 /* {
    path: '/items',
    component: Layout,
    redirect: 'noredirect',
    alwaysShow: true,
    name: 'itemsManage',
    meta: {
      title: '服务大厅',
      icon: 'example'
    },
    children: [
      { path: 'items', component: _import('items/items'), name: 'items', meta: { title: '事项管理', icon: 'documentation',noCache: true }}
    ]
  },*/
  /*{
    path: '/user',
    component: Layout,
    redirect: 'noredirect',
    name: 'userManage',
    meta: {
      title: '用户管理',
      icon: 'people'
    },
    children: [
      { path: 'user', component: _import('user/user'), name: 'user', meta: { title: '已审核用户', noCache: true }},
      { path: 'checkUser', component: _import('user/checkUser'), name: 'checkUser', meta: { title: '待审核用户', noCache: true }},
      { path: 'userDetail', component: _import('user/userDetail'), name: 'userDetail', meta: { title: '会员详情', noCache: false, hideTag: true, hidden: true }}
    ]
  },*/
  /*{
    path: '/community',
    component: Layout,
    redirect: 'noredirect',
    name: 'communityManage',
    meta: {
      title: '窗口管理',
      icon: 'example'
    },
    children: [
      { path: 'industry', component: _import('organize/organizeTrade'), name: 'industry', meta: { title: '委办局管理',icon: 'example', noCache: true }}
    ]
  },*/
  {
    path: '/content',
    component: Layout,
    redirect: 'noredirect',
    name: 'contentManage',
    meta: {
      title: '内容&互动',
      icon: 'language'
    },
    children: [
      { path: 'bannerManage', component: _import('content/banner'), name: 'bannerManage', meta: { title: 'Banner管理', noCache: true }},
      { path: 'administrationInfo', component: _import('content/index'), name: 'administrationInfo', meta: { title: '科大要闻', noCache: true }},
      { path: 'servicePacesetter', component: _import('content/index'), name: 'servicePacesetter', meta: { title: '学生标兵', noCache: true }},
      { path: 'centraActivities', component: _import('content/index'), name: 'centraActivities', meta: { title: '校园动态', noCache: true }},
/*      { path: 'reading', component: _import('content/index'), name: 'reading', meta: { title: '悦读', noCache: true }},
      { path: 'notice', component: _import('content/index'), name: 'notice', meta: { title: '公告管理', noCache: true }},
      { path: 'comment', component: _import('content/comment'), name: 'comment', meta: { title: '评论管理', noCache: true }},*/
      { path: 'questions', component: _import('content/questions'), name: 'questions', meta: { title: '咨询投诉', noCache: true }},
    ]
  },
  {
    path: '/sys',
    component: Layout,
    redirect: 'noredirect',
    name: 'sysManage',
    meta: {
      title: '系统管理',
      icon: 'chart'
    },
    children: [
      { path: 'message', component: _import('sys/admin'), name: 'message', meta: { title: '系统消息', noCache: true, hideTag: true }},
      { path: 'sms', component: _import('sys/admin'), name: 'sms', meta: { title: '短信通知', noCache: true, hideTag: true }},
      { path: 'admin', component: _import('sys/admin'), name: 'admin', meta: { title: '员工管理', noCache: true }},
      { path: 'role', component: _import('sys/role'), name: 'role', meta: { title: '角色管理', noCache: true }},
      { path: 'os', component: _import('sys/os'), name: 'os', meta: { title: '对象存储', noCache: true, hideTag: true }}
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]
