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

Vue.use(Router);

/* Layout */
import Layout from '@/pages/layout/layout';

/* Router Modules */
// 管理员管理
import adminManageRouter from './modules/admin-manage';
// 授权主体管理
import authSubjectManageRouter from './modules/auth-subject-manage';
// 授权客体管理
import authObjectManageRouter from './modules/auth-object-manage';
// 应用功能授权管理
import appfunAuthManageRouter from './modules/appfun-auth-manage';
// 数据授权管理
import dataAuthManageRouter from './modules/data-auth-manage';
// 名单管理
import listManageRouter from './modules/list-manage';
// 日志管理
import logManage from './modules/log-manage';
// 统计报表
import statisticsManageRouter from './modules/statistics-manage';
import logReport from './modules/log-report';



/** note: Submenu only appear 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
 *                                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 redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    permission: ['menu_key1',"menu_key2"]    will control the page permission (you can set multiple permissions)
    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)
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
  }
 **/
export const constantRouterMap = [];

export const asyncRouterMap = [
  {
    path: '/',
    component: Layout,
    redirect: '/home'
  },
  // 全文匹配
  {
    path: '*',
    redirect: '/'
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/pages/common/redirect/index')
      }
    ]
  },
  // 登录
  {
    path: '/login',
    component: () => import('@/pages/common/login/index'),
    // component: () => import("@/pages/common/login-page/login-type-1"),
    hidden: true
  },
  // 我的主页
  {
    path: '/home',
    component: Layout,
    redirect: '/home/index',
    meta: { title: '我的主页', icon: 'icon-home', noCache: true },
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/pages/home'),
        name: 'index',
        meta: { title: '我的主页', noCache: true }
      }
    ]
  },
  adminManageRouter,
  authSubjectManageRouter,
  authObjectManageRouter, 
  appfunAuthManageRouter,
  // 服务授权管理
  {
    path: '/service-auth-manage',
    component: Layout,
    meta: { title: '服务授权管理', icon: 'icon-fwsqgl', noCache: true, permission: ['QXGL_SQGL_FWSQGL'] },
    children: [
      {
        path: 'init',
        component: () => import('@/pages/service-auth-manage'),
        name: 'service-auth-manage',
        meta: { title: '服务授权管理', noCache: true, permission: ['QXGL_SQGL_FWSQGL'] }
      }
    ]
  },
  dataAuthManageRouter,
  // 权限自助管理
  {
    path: '/permission-selfhelp-manage',
    component: Layout,
    meta: { title: '权限自助管理', icon: 'icon-handle', noCache: true },
    children: [
      {
        path: 'init',
        component: () => import('@/pages/permission-selfhelp-manage'),
        name: 'permission-selfhelp-manage',
        meta: { title: '权限自助管理', noCache: true }
      }
    ]
  },
  {
    path: '/data-auth-search',
    component: Layout,
    meta: { title: '数据权限查询', icon: 'icon-othersearch', noCache: true },
    children: [
      {
        path: 'init',
        component: () => import('@/pages/permission-to-search/data-auth-search.vue'),
        name: 'data-auth-search',
        meta: { title: '数据权限查询', noCache: true, layout: "page" }
      }
    ]
  },
  // 权限综合查询
  // {
  //   path: '/permission-to-searchS',
  //   component: Layout,
  //   meta: { title: '权限综合查询', icon: 'icon-othersearch', noCache: true, permission: ['QXGL_SQCX'] },
  //   children: [
  //     {
  //       path: 'data-auth-search',
  //       component: () => import('@/pages/permission-to-search/data-auth-search.vue'),
  //       name: 'data-auth-search',
  //       meta: { title: '数据权限查询', noCache: true, layout: 'page',  permission: ['QXGL_SQCX_SJSQCX'] }
  //     }
  //   ]
  // },
  listManageRouter,
  ...logManage,
  statisticsManageRouter
];

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