import Vue from 'vue'
import VueRouter from 'vue-router'
//登陆页面
import login from '../views/login.vue'
//主页菜单
import homepage from "../views/homepage.vue";
//矿区监控
import mineMonitoring from '../views/mineMonitoring.vue'
//视频监控
import videoSurveillance from '../views/videoSurveillance.vue'
//生产自动化系统
import AutomationHomepage from '../views/AutomationHomepage.vue'
import AutomatedNowData from '../views/AutomatedNowData.vue'
import AutomationHistory from '../views/AutomationHistory.vue'
import AutomaticAlarm from '../views/AutomaticAlarm.vue'
//生产报表系统
import ReportHomePage from '../views/ReportHomePage.vue'
import ReportNowData from '../views/ReportNowData.vue'
import ReportHistory from '../views/ReportHistory.vue'
//人员定位系统
import PersonnelPositioning from '../views/PersonnelPositioning.vue'
//车辆定位系统
import CarPositioning from '../views/CarPositioning.vue'
//边坡在线监测
import SlopeHomePage from '../views/SlopeHomePage.vue'
import SlopeNowData from '../views/SlopeNowData.vue'
import SlopeHistory from '../views/SlopeHistory.vue'
import SlopeAlarm from '../views/SlopeAlarm.vue'
//环境在线监测
import EnvironmentHomepage from '../views/EnvironmentHomepage.vue'
import EnvironmentNowData from '../views/EnvironmentNowData.vue'
import EnvironmentHistory from '../views/EnvironmentHistory.vue'
import EnvironmentAlarm from '../views/EnvironmentAlarm.vue'
//数字化储量管理
import reservesHomepage from '../views/reservesHomepage.vue'
//门禁系统
import AccessHomepage from '../views/AccessHomepage.vue'

Vue.use(VueRouter)
//解决vue中路由冗余导航报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


const routes = [
  //登陆页面
  {
    path: '/login',
    name: 'login',
    component: login
  },
  //主页菜单
  {
    path: '/homepage',
    name: 'homepage',
    component: homepage,
    children: [
      //矿区监控
      {
        path: '/homepage/mineMonitoring',
        component: mineMonitoring
      },
      //视频监控
      {
        path: '/homepage/videoSurveillance',
        component: videoSurveillance
      },
      //生产自动化系统
      {
        path: '/homepage/AutomationHomepage',
        component: AutomationHomepage
      },{
        path: '/homepage/AutomatedNowData',
        component: AutomatedNowData
      },{
        path: '/homepage/AutomationHistory',
        component: AutomationHistory
      },{
        path: '/homepage/AutomaticAlarm',
        component: AutomaticAlarm
      },
      //生产报表系统
      {
        path: '/homepage/ReportHomePage',
        component: ReportHomePage
      },{
        path: '/homepage/ReportNowData',
        component: ReportNowData
      },{
        path: '/homepage/ReportHistory',
        component: ReportHistory
      },
      //人员定位系统
      {
        path: '/homepage/PersonnelPositioning',
        component: PersonnelPositioning
      },
      //车辆定位系统
      {
        path: '/homepage/CarPositioning',
        component: CarPositioning
      },
      //边坡在线监测
      {
        path: '/homepage/SlopeHomePage',
        component: SlopeHomePage
      },{
        path: '/homepage/SlopeNowData',
        component: SlopeNowData
      },{
        path: '/homepage/SlopeHistory',
        component: SlopeHistory
      },{
        path: '/homepage/SlopeAlarm',
        component: SlopeAlarm
      },
      //环境在线监测
      {
        path: '/homepage/EnvironmentHomepage',
        component: EnvironmentHomepage
      },{
        path: '/homepage/EnvironmentNowData',
        component: EnvironmentNowData
      },{
        path: '/homepage/EnvironmentHistory',
        component: EnvironmentHistory
      },{
        path: '/homepage/EnvironmentAlarm',
        component: EnvironmentAlarm
      },
      //数字化储量管理
      {
        path: '/homepage/reservesHomepage',
        component: reservesHomepage
      },
      //门禁系统
      {
        path: '/homepage/AccessHomepage',
        component: AccessHomepage
      },
    ]
  },
  //  //懒加载
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // },
  //路由重定向
  {
    name: 'default',
    path: '*',
    redirect: '/login'
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
