import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout'
Vue.use(Router)
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/404',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/404',
        component: () => import('@/views/404'),
        meta: { title: '404', icon: 'user', noCache: true }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]
export var routeViews = [
  {
    path: '/',
    component: Layout,
    name: 'Home',
    redirect: '/home',
    children: [
      {
        path: 'home',
        component: () => import('@/views/home'),
        name: 'home',
        meta: { title: '首页', icon: 'el-icon-s-platform', affix: true }
      }
    ]
  },
  {
    path: '/receiveUnit',
    component: Layout,
    name: 'receive-unit',
    redirect: '/receiveUnit/list',
    children: [
      {
        path: 'list',
        component: () => import('@/views/receiveUnit'),
        name: 'receiveUnit',
        meta: { title: '上报安全风险单元数据', icon: 'el-icon-document', affix: true }
      }
    ]
  },
  {
    path: '/receiveEvent',
    component: Layout,
    name: 'receive-list',
    redirect: '/receiveEvent/list',
    children: [
      {
        path: 'list',
        component: () => import('@/views/receiveEvent'),
        name: 'receiveEvent',
        meta: { title: '上报安全风险事件数据', icon: 'el-icon-document', affix: true }
      }
    ]
  },
  {
    path: '/getLog',
    component: Layout,
    name: 'getLog-list',
    redirect: '/getLog/list',
    children: [
      {
        path: 'list',
        component: () => import('@/views/getLog'),
        name: 'getLog',
        meta: { title: '处理结果', icon: 'el-icon-document', affix: true }
      }
    ]
  },
  {
    path: '/getErrLog',
    component: Layout,
    name: 'getErrLog-list',
    redirect: '/getErrLog/list',
    children: [
      {
        path: 'list',
        component: () => import('@/views/getErrLog'),
        name: 'getErrLog',
        meta: { title: '错误信息', icon: 'el-icon-document', affix: true }
      }
    ]
  }
]
const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: [...constantRoutes, ...routeViews]
})

const router = createRouter()
export default router

