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

// 解决：浏览器前进后退按钮，页面跳转，导致的浏览器控制台报错
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);
};


Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    redirect: "/"
  } ,
  // 整车性能DVP-基本信息
  {
    path: "/vehicleInfo",
    name: "fullVehicle",
    component: () => import("@/views/fullVehicle/baseInfo/index")
  },
    // 整车性能DVP-计划
  {
    path: "/dvpPlan",
    name: "dvpPlan",
    component: () => import("@/views/fullVehicle/dvpPlan/index")
  } ,
  // 整车性能DVP-DVP验证
  {
    path: "/dvpVerify",
    name: "dvpVerify",
    component: () => import("@/views/fullVehicle/verify/dvpVerify")
  },
  // 系统DVP-基本信息
  {
    path: "/systemDVP",
    name: "systemDVP",
    component: () => import("@/views/systemDVP/baseInfo/index")
  },
  // 系统DVP-计划
  {
    path: "/sysDvpPlan",
    name: "sysDvpPlan",
    component: () => import("@/views/systemDVP/dvpPlan/index")
  },
  // 系统DVP-DVP验证
  {
    path: "/sysDvpVerify",
    name: "dvpVerify",
    component: () => import("@/views/systemDVP/verify/dvpVerify")
  },
  // 零部件DVP-基本信息
  {
    path: "/componentsDVP",
    name: "componentsDVP",
    component: () => import("@/views/componentsDVP/baseInfo/index")
  },
  // 零部件DVP跳转 基本信息编辑页
  {
    path: "/componentsDVP/dvpPlan/edit",
    name: "componentsDVP:dvpPlan:edit",
    component: () => import ('@/views/componentsDVP/dvpPlan/edit'),
  },
  // 零部件DVP-计划
  {
    path: "/componentsDvpPlan",
    name: "componentsDvpPlan",
    component: () => import("@/views/componentsDVP/dvpPlan/index")
  },
  // 零部件DVP-DVP验证
  {
    path: "/componentsDvpVerify",
    name: "componentsDvpVerify",
    component: () => import("@/views/componentsDVP/verify/dvpVerify")
  },
  // 403页面
  {
    path: "/forbiddenAuthority",
    name: "forbiddenAuthority",
    component: () => import("@/views/exception/403")
  },

];

const router = new VueRouter({
  mode: "hash", //history hash
  base: process.env.VUE_APP_MERGE == 1 ? process.env.VUE_APP_BASE_URL_DVP : "",
  routes
});
export default router;
