南昌市物联网技防平台-前端
liuyg
2021-04-16 105fe4e018b7efb169f36573cad031e792f28f93
刷新保留
1 files modified
75 ■■■■■ changed files
src/page/crumbsL/crumbsL.vue 75 ●●●●● patch | view | raw | blame | history
src/page/crumbsL/crumbsL.vue
@@ -26,12 +26,12 @@
      //手动配置项:breadListIm为路由与面包屑名称对应关系,breadLoadName为面包屑组件路由
      upName: {
        监控台: "welcomeData",
        预警管理: "alarmManagement",
        预警管理1: "alarmManagement",
        预警管理: "realTimePolice",
        客户管理: "suser",
        设备管理: "clientManagement",
        研判洞察: "home",
        报表管理: "report",
        报表管理1: "report",
        报表管理: "myiframe",
        报表配置: "urlPath",
        警情调度: "policeInformationDistribution",
@@ -58,35 +58,37 @@
      ],
      breadListLast: [],
      sOld: -1,
      isrf: false
      isrf: false,
    };
  },
  methods: {
    loadChange(states) {//导航栏进就是一级路由,其他页面push
    loadChange(states) {
      //导航栏进就是一级路由,其他页面push
    if(this.isrf){
      this.breadListLast = JSON.parse(localStorage.getItem('crumbsl'));
        this.breadListLast = JSON.parse(localStorage.getItem("crumbsl"));
    }else{
        var path = this.$route.path,
            p = path.split('/').pop(),
          p = path.split("/").pop(),
            n = this.$route.name,
            s = this.$store.state.common.liuState;
        console.log('path:' + p);
        console.log('name:' + n);
        console.log('state:  ' , s);
        if(this.sOld != s){//一级菜单
        console.log("path:" + p);
        console.log("name:" + n);
        console.log("state:  ", s);
        if (this.sOld != s) {
          //一级菜单
        this.breadListLast = [];
        this.breadListLast.push({
          name: n == '首页'? '数据模式': n,
          path: path
        })
        console.log(p,n,'写入一级面包屑');
        }else if(this.sOld == s){//push
            name: n == "首页" ? "数据模式" : n,
            path: path,
          });
          console.log(p, n, "写入一级面包屑");
        } else if (this.sOld == s) {
          //push
          this.breadListLast.push({
            name: n,
            path: path
          })
            path: path,
          });
          //判断是否有重复项,有则删除其后路由↓
          var ourP = this.breadListLast;
          for (var os in ourP) {
@@ -97,14 +99,16 @@
              );
            }
          }
            console.log(p,n,'写入多级面包屑');
          console.log(p, n, "写入多级面包屑");
        }
        this.sOld = s;
        // window.localStorage.crumbsl = this.breadListLast;
        localStorage.setItem('crumbsl', JSON.stringify(this.breadListLast));
        localStorage.setItem("crumbsl", JSON.stringify(this.breadListLast));
      }
    },
    loadChange2(states) {//逐级添加  暂时不用
    loadChange2(states) {
      //逐级添加  暂时不用
      var path = this.$route.path.split("/"),
        up = {};
      path.shift();
@@ -185,6 +189,7 @@
      // console.log("data::", this.breadListLast);
    },
    loadChanges() {
      //单个路由  暂时不用
      this.breadListLast = [
        // {
        //     name: '首页',
@@ -261,19 +266,6 @@
        console.log("未识别到路由");
      }
    },
    cc(){
      var a = window.localStorage.crumbslOver,
           b = window.localStorage.crumbslBegin;
      var c = a - b;
      console.log(c)
      if(+ c < 11000){
        this.isrf = true;
        console.log('是刷新')
      }else{
        this.isrf = false;
        console.log('是关闭了再启动')
      }
    }
  },
  watch: {
    $route(to, from) {
@@ -284,15 +276,14 @@
  },
  //页面挂载之后,解析路由,给出面包屑,路由里面一定要含有breadCom组件的path
  mounted: function () {
    window.onunload = (e)=>{
      var nowTime = new Date().getTime();
      window.localStorage.crumbslOver = nowTime
    if (window.name == "") {
      this.isrf = false;
      console.log("首次被加载");
      window.name = "isReload"; // 在首次进入页面时我们可以给window.name设置一个固定值
    } else if (window.name == "isReload") {
      this.isrf = true;
      console.log("页面被刷新");
    }
    window.onload = (e)=>{
      var nowTime = new Date().getTime();
      window.localStorage.crumbslBegin = nowTime
    }
    this.cc();
    this.loadChange("moun");
  },
};