import Vue from 'vue'
import Router from 'vue-router'
/* Layout */
import Layout from '@/layout'
import axios from 'axios'
import store from '../store/index'

Vue.use(Router)

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: '/dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: '首页' }
    }]
  },

  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/elk',
  //   children: [{
  //     path: '/ELK',
  //     name: 'ELK',
  //     component: () => import('@/views/ELK/index'),
  //     meta: { title: '111111', icon: '' }
  //   }]
  // },

  // {
  //     path: '/bj',
  //     component: Layout,
  //     children: [{
  //         path: 'list',
  //         name: 'list',
  //         component: () => import('@/views/alarmInformation/index'),
  //         meta: { title: '报警信息列表', icon: 'dashboard' }
  //     }]
  // },
  {
    path: '/bj',
    component: Layout,
    hidden: true,
    children: [{
      path: '/alarmDetail',
      name: '/alarmDetail',
      component: () => import('@/views/alarmInformation/alarmDetail'),
      meta: { title: '报警信息详情', icon: 'dashboard' }
    }]
  },
  {
    path: '/system',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'type',
        name: 'type',
        component: () => import('@/views/system/department-dict/type/index'),
        meta: { title: '系统字典维护', icon: 'form' },
        hidden: true
      }
    ]
  },
  {
    path: '/system',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'lineType',
        name: 'lineType',
        component: () => import('@/views/system/line-dict/type/index'),
        meta: { title: '系统字典维护', icon: 'form' },
        hidden: true
      }
    ]
  },

  // {
  //     path: '/video',
  //     component: Layout,
  //     children: [{
  //         path: 'videoService',
  //         name: 'videoService',
  //         component: () => import('@/views/videoService/index'),
  //         meta: { title: '视频服务', icon: 'dashboard' }
  //     }]
  // },
  // {
  //     path: '/account',
  //     component: Layout,
  //     redirect: '/account/camera',
  //     name: 'Account',
  //     meta: { title: '台账管理', icon: 'el-icon-s-help' },
  //     children: [
  //         {
  //             path: 'camera',
  //             name: 'camera',
  //             component: () => import('@/views/account/camera/index'),
  //             meta: { title: '相机台账管理', icon: 'table' }
  //         },
  //         {
  //             path: 'line',
  //             name: 'line',
  //             component: () => import('@/views/account/line/index'),
  //             meta: { title: '线路台账管理', icon: 'tree' }
  //         }
  //     ]
  // },
  // {
  //     path: '/sum',
  //     component: Layout,
  //     children: [{
  //         path: '/sum/sum',
  //         name: 'sum',
  //         component: () => import('@/views/sum/index'),
  //         meta: { title: '数据统计', icon: 'dashboard' }
  //     }]
  // },
  // {
  //     path: '/system',
  //     component: Layout,
  //     redirect: '/system/user',
  //     name: 'user',
  //     meta: { title: '系统管理', icon: 'el-icon-s-help' },
  //     children: [
  // {
  //     path: 'user',
  //     name: 'User',
  //     component: () => import('@/views/system/user/index'),
  //     meta: { title: '用户管理', icon: 'table' }
  // },
  // {
  //     path: 'role',
  //     name: 'role',
  //     component: () => import('@/views/system/role/index'),
  //     meta: { title: '角色管理', icon: 'tree' }
  // },
  // {
  //     path: 'department',
  //     name: 'department',
  //     component: () => import('@/views/system/department/index'),
  //     meta: { title: '部门管理', icon: 'table' }
  // },
  // {
  //     path: 'menu',
  //     name: 'menu',
  //     component: () => import('@/views/system/menu/index'),
  //     meta: { title: '菜单管理', icon: 'tree' }
  // },
  // {
  //     path: 'department-dict',
  //     name: 'department-dict',
  //     component: () => import('@/views/system/department-dict/index'),
  //     meta: { title: '部门字典数据维护', icon: 'tree' },
  // },
  // {
  //     path: 'type',
  //     name: 'type',
  //     component: () => import('@/views/system/line-dict/index'),
  //     meta: { title: '字典类型下钻', icon: 'form' },
  //     hidden: true
  // },
  // {
  //     path: 'line-dict',
  //     name: 'line-dict',
  //     component: () => import('@/views/system/line-dict/index'),
  //     meta: { title: '线路字典数据维护', icon: 'tree' },
  // },
  // {
  //     path: 'lineType',
  //     name: 'lineType',
  //     component: () => import('@/views/system/line-dict/type/index'),
  //     meta: { title: '线路字典类型下钻', icon: 'form' },
  //     hidden: true
  // },
  // {
  //     path: 'operation',
  //     component: () => import('@/views/log/operation/index'), // Parent router-view
  //     name: 'operation',
  //     meta: { title: '操作日志', icon: 'dashboard' },
  // },
  // {
  //     path: 'login',
  //     component: () => import('@/views/log/login/index'),
  //     name: 'login',
  //     meta: { title: '登录日志', icon: 'dashboard' }
  // }
  // ]
  // },
  {
    path: '/message',
    component: Layout,
    hidden: true,
    children: [{
      path: 'list',
      name: 'list',
      component: () => import('@/views/message/index'),
      meta: { title: '更多消息', icon: 'dashboard' }
    }]
  },
  {
    path: '/personalCenter',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'list',
        name: 'list',
        component: () => import('@/views/personalCenter/index'),
        meta: { title: '个人中心' }
      }
    ]
  }
// 404 page must be placed at the end !!!
// { path: '*', redirect: '/', hidden: true }
]

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

const router = createRouter()

/**
 * 递归加载路由组件
 * @param asyncRouterMap 可获取的路由列表
 * @returns {*}
 */

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}
export default router
