From 105fe4e018b7efb169f36573cad031e792f28f93 Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Fri, 16 Apr 2021 09:07:30 +0800
Subject: [PATCH] 刷新保留

---
 src/page/crumbsL/crumbsL.vue |  123 +++++++++++++++++++----------------------
 1 files changed, 57 insertions(+), 66 deletions(-)

diff --git a/src/page/crumbsL/crumbsL.vue b/src/page/crumbsL/crumbsL.vue
index 44025da..c8faea3 100644
--- a/src/page/crumbsL/crumbsL.vue
+++ b/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,53 +58,57 @@
       ],
       breadListLast: [],
       sOld: -1,
-      isrf: false
+      isrf: false,
     };
   },
   methods: {
-    loadChange(states) {//导航栏进就是一级路由,其他页面push
-    if(this.isrf){
-      this.breadListLast = JSON.parse(localStorage.getItem('crumbsl'));
-    }else{
+    loadChange(states) {
+      //导航栏进就是一级路由,其他页面push
+      if (this.isrf) {
+        this.breadListLast = JSON.parse(localStorage.getItem("crumbsl"));
+      } else {
         var path = this.$route.path,
-            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){//一级菜单
-        this.breadListLast = [];
-        this.breadListLast.push({
-          name: n == '首页'? '数据模式': n,
-          path: path
-        })
-        console.log(p,n,'写入一级面包屑');
-        }else if(this.sOld == s){//push
-
+          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) {
+          //一级菜单
+          this.breadListLast = [];
+          this.breadListLast.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) {
             if (ourP[os].name == n && os != ourP.length - 1) {
               this.breadListLast.splice(
-                + os + 1,
+                +os + 1,
                 this.breadListLast.length - os - 1
               );
             }
           }
-            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();
@@ -117,28 +121,28 @@
       if (states == "moun") {
         //第一次进入页面
         // for (var uk in path) {
-          // if (uk < path.length - 1) {
-            // continue;
-          // }
+        // if (uk < path.length - 1) {
+        // continue;
+        // }
 
-          if (this.$route.name != "首页") {
-            up = {
-              // name: path[uk] + (+uk + 1),
-              // name: path[uk],
-              name: "首页",
-              path: "/wel",
-            };
-          }
-          //首页:
-
-          this.breadListLast.push(up);
+        if (this.$route.name != "首页") {
           up = {
             // name: path[uk] + (+uk + 1),
             // name: path[uk],
-            name: this.$route.name,
-            path: this.$route.path,
+            name: "首页",
+            path: "/wel",
           };
-          this.breadListLast.push(up);
+        }
+        //首页:
+
+        this.breadListLast.push(up);
+        up = {
+          // name: path[uk] + (+uk + 1),
+          // name: path[uk],
+          name: this.$route.name,
+          path: this.$route.path,
+        };
+        this.breadListLast.push(up);
         // }
       } else if (states == "rout") {
         //向后添加面包屑
@@ -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");
   },
 };

--
Gitblit v1.9.3