import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  // {
  //   path: "/",
  //   redirect: "/login",
  // },
  {
    path: "/",
    component: () =>
      import(/* webpackChunkName: "home" */ "../components/common/Home.vue"),
    meta: { title: "首页" },
    redirect: "/realTimeMonitor",
    children: [
      {
        path: "/stritl",
        component: () =>
          import(
            /* webpackChunkName: "dashboard" */ "../views/stritl/index.vue"
          ),
        meta: {
          title: "系统首页",
          icon: "el-icon-s-home",
        },
      },

      {
        path: "/realTimeMonitor",
        component: () =>
          import(
            /* webpackChunkName: "icon" */ "../views/realTimeMonitor/index.vue"
          ),
        meta: {
          title: "实时监控",
          permission: true,
          icon: "el-icon-camera",
        },
      },

      {
        path: "/pictureRotation",
        component: () =>
          import(
            /* webpackChunkName: "table" */ "../views/pictureRotation/index.vue"
          ),
        meta: {
          title: "图片轮巡",
          permission: true,
          icon: "el-icon-film",
        },
      },
      {
        path: "/photoAlarm",
        component: () =>
          import(
            /* webpackChunkName: "tabs" */ "../views/alarmHandling/index.vue"
          ),
        meta: { title: "告警处理", icon: "el-icon-bell" },
      },
      {
        path: "/realTimeSearch",
        component: () =>
          import(
            /* webpackChunkName: "tabs" */ "../views/realTimeSearch/index.vue"
          ),
        meta: { title: "实时查询", icon: "el-icon-search" },
      },
      {
        path: "/lineInformation",
        component: () =>
          import(
            /* webpackChunkName: "tabs" */ "../views/management/userEquipment/lineInformation/index.vue"
          ),
        meta: { title: "线路信息管理", icon: "" },
      },
      {
        path: "/towerInformation",
        component: () =>
          import(
            /* webpackChunkName: "tabs" */ "../views/management/userEquipment/towerInformation/index.vue"
          ),
        meta: { title: "杆塔信息管理", icon: "" },
      },
      {
        path: "/photographicDevice",
        component: () =>
          import(
            /* webpackChunkName: "tabs" */ "../views/management/monitoringEquipment/photographicDevice/index.vue"
          ),
        meta: { title: "拍照装置管理", icon: "" },
      },
      {
        path: "/cameraChannel",
        component: () =>
          import(
            /* webpackChunkName: "icon" */ "../views/cameraChannel/index.vue"
          ),
        meta: {
          title: "通道设置",

          icon: "el-icon-coin",
        },
      },
      {
        path: "/devicePhotoSchedule",
        component: () =>
          import(
            /* webpackChunkName: "tabs" */ "../views/devicePhotoSchedule/index.vue"
          ),
        meta: { title: "拍照时间表设置", icon: "el-icon-setting" },
      },

      {
        path: "/imageSettings",
        component: () =>
          import(
            /* webpackChunkName: "tabs" */ "../views/imageSettings/index.vue"
          ),
        meta: { title: "图像采集装置设置", icon: "el-icon-picture-outline" },
      },
      {
        path: "/deviceUpgrade",
        component: () =>
          import(
            /* webpackChunkName: "tabs" */ "../views/deviceUpgrade/index.vue"
          ),
        meta: { title: "装置升级", icon: "el-icon-picture-outline" },
      },
      {
        path: "/userManagement",
        component: () =>
          import(
            /* webpackChunkName: "tabs" */ "../views/system/userManagement.vue"
          ),
        meta: { title: "用户管理", icon: "el-icon-monitor" },
      },
      {
        path: "/globalTools",
        component: () =>
          import(
            /* webpackChunkName: "tabs" */ "../views/system/globalTools/index.vue"
          ),
        meta: { title: "全局设置" },
      },

      // {
      //   path: "/videoMonitor",
      //   component: () =>
      //     import(
      //       /* webpackChunkName: "tabs" */ "../views/videoMonitor/index.vue"
      //     ),
      //   meta: { title: "监控视频", icon: "el-icon-video-camera" },
      // },
      // {
      //   path: "/videoHistory",
      //   component: () =>
      //     import(
      //       /* webpackChunkName: "tabs" */ "../views/videoMonitor/videoHistory.vue"
      //     ),
      //   meta: { title: "视频回放", icon: "el-icon-video-camera" },
      // },

      // {
      //   path: "/groupInformation",
      //   component: () =>
      //     import(
      //       /* webpackChunkName: "tabs" */ "../views/management/userEquipment/groupInformation/index.vue"
      //     ),
      //   meta: { title: "分组信息管理", icon: "" },
      // },

      // {
      //   path: "/towerTeam",
      //   component: () =>
      //     import(
      //       /* webpackChunkName: "tabs" */ "../views/management/userEquipment/towerTeam/index.vue"
      //     ),
      //   meta: { title: "杆塔班组用户", icon: "" },
      // },

      {
        path: "/404",
        component: () =>
          import(/* webpackChunkName: "404" */ "../views/404.vue"),
        meta: { title: "404" },
      },
    ],
  },
  {
    path: "/login",
    component: () =>
      import(/* webpackChunkName: "login" */ "../views/Login.vue"),
    meta: { title: "登录" },
  },
  {
    path: "*",
    redirect: "/404",
  },
];

const router = new VueRouter({
  mode: "hash",
  base: process.env.BASE_URL,
  routes,
});
/**
 *	重写 router.prototype.push 避免同时跳转相同路径报错
 */
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch((err) => err);
};
export default router;
