import Vue from 'vue'
import Router from 'vue-router'
import index from '../../src/page/index/index.vue'

//首页
import login from '../../src/page/login/login.vue'
//首页
import home from '../../src/page/home/Home.vue'
// 测报灯
import Cbd from '../../src/page/cbd/Cbd.vue'
import pestsStats from '../../src/page/cbd/analyse.vue'
import cbdDataPhotos from '../../src/page/cbd/cbdDataPhotos.vue'
import cbdCanvas from '../../src/page/cbd/cbdCanvas.vue'
import MessageWarn from '../../src/page/cbd/MessageWarn.vue'
import cbdDataDetails from '../../src/page/cbd/DataDetails.vue'
//气象站
import envi from '../../src/page/qxz/envi.vue'
import Data24 from '../../src/page/qxz/Data24.vue'
import HistoryData from '../../src/page/qxz/HistoryData.vue'
//孢子仪
import bzy from '../../src/page/bzy/bzy.vue'
import bzyPhotos from '../../src/page/bzy/BzyPhotos.vue'
import dataDetail from '../../src/page/bzy/DataDetail.vue'
//监控
import monitor from '../../src/page/monitor/Monitor.vue'
import photoView from '../../src/page/monitor/PhotoView.vue'
import playback from "../../src/page/monitor/playback.vue"

//墒情站
import sqz from '../../src/page/sqz/sqz.vue'
import sqzData24 from '../../src/page/sqz/Data24.vue'
import sqzHistoryData from '../../src/page/sqz/HistoryData.vue'

//农作物管理
import crop from '../../src/page/crop/crop.vue'
import cropadd from '../../src/page/crop/cropadd.vue'
import evildata from '../../src/page/crop/evildata.vue'

//基地管理
import baselist from '../../src/page/base/baselist.vue'
import plotlist from '../../src/page/base/plotlist.vue'
import maphandle from '../../src/page/base/maphandle.vue'
import maofacility from '../../src/page/base/maofacility.vue'
import mapplot from '../../src/page/base/mapplot.vue'

//预警
import earlywarning from '../../src/page/worn/earlywarning.vue'
//故障
import faultinfo from '../../src/page/fault/faultinfo.vue'
//gis
import gisshow from '../../src/page/gis/gisshow.vue'
//用户列表
import userlist from '../../src/page/user/userlist.vue'
//专家
import specialist from '../../src/page/specialist/specialist.vue'
//接入设备
import joincbd from '../../src/page/join/joincbd.vue'
import joinqxz from '../../src/page/join/joinqxz.vue'
Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/login',
    },
    {
      path: '/login',
      component: login,
    },
    {
      path: '/index',
      component: index,
      children: [
        {
          path: '/',
          redirect: "/index/home"
        },
        {
          path: 'home',
          component: home
        },
        {
          path: 'Cbd',
          component: Cbd,
          meta: {
            keepAlive: true, //留存数据
          }
        },
        {
          path: 'pestsStats',
          component: pestsStats
        },
        {
          path: 'cbdDataPhotos/:id',
          component: cbdDataPhotos
        },
        {
          path: 'cbdCanvas',//canvas绘制测报灯图片坐标
          component: cbdCanvas,
        },
        {
          path: 'MessageWarn/:id',//canvas绘制测报灯图片坐标
          component: MessageWarn,
        },
        {
          path: 'cbdDataDetails/:e_id/:d_id',//canvas绘制测报灯图片坐标
          component: cbdDataDetails,
        },
        {
          path: 'envi',
          component: envi,
          meta: {
            keepAlive: true, //留存数据
          }
        }, {
          path: 'Data24/:id',
          component: Data24
        }, {
          path: 'HistoryData/:id/:d_id',
          component: HistoryData
        }, {
          path: 'bzy',
          component: bzy,
          meta: {
            keepAlive: true, //留存数据
          }
        }, {
          path: 'bzyPhotos/:id',
          component: bzyPhotos
        }, {
          path: 'dataDetail/:e_id/:d_id',
          component: dataDetail
        }, {
          path: 'monitor',
          component: monitor
        }, {
          path: 'photoView/:id',
          component: photoView
        }, {
          path: 'playback',
          component: playback
        }, {
          path: 'sqz',
          component: sqz,
          meta: {
            keepAlive: true, //留存数据
          }
        }, {
          path: 'sqzData24/:id',
          component: sqzData24
        }, {
          path: 'sqzHistoryData/:id/:d_id',
          component: sqzHistoryData
        }, {
          path: 'crop',
          component: crop
        }, {
          path: 'cropadd',
          component: cropadd
        }, {
          path: "evildata",
          component: evildata
        }, {
          path: "baselist",
          component: baselist,
          meta: {
            keepAlive: true, //留存数据
          }
        }, {
          path: "plotlist",
          component: plotlist
        }, {
          path: "maphandle",
          component: maphandle
        }, {
          path: "maofacility",
          component: maofacility
        }, {
          path: "mapplot",
          component: mapplot
        }, {
          path: "earlywarning",
          component: earlywarning
        }, {
          path: "faultinfo",
          component: faultinfo
        }, {
          path: "gisshow",
          component: gisshow
        }, {
          path: "userlist",
          component: userlist
        }, {
          path: "specialist",
          component: specialist
        }, {
          path: "joinqxz",
          component: joinqxz
        }, {
          path: "joincbd",
          component: joincbd
        },

      ]
    }
  ]
})
// 解决导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
