SunZehao před 5 měsíci
rodič
revize
0ad3a018db
1 změnil soubory, kde provedl 21 přidání a 13 odebrání
  1. 21 13
      src/App.vue

+ 21 - 13
src/App.vue

@@ -122,8 +122,8 @@
         </ul>
       </div>
       <!-- :style="{ paddingLeft: fixed ? '65px' : 0 }"  :style="{ paddingLeft: isShowMenu ? '65px' : 0 }"-->
-      <!-- :style="pagestyFn()" -->
-      <div class="pageSty" :style="pagestyFn()">
+      <!-- :style="pagestyFn()"  :class="pageClaFn()" -->
+      <div class="pageSty" :style="pagestyFn(routepath)">
         <router-view />
       </div>
     </div>
@@ -989,18 +989,27 @@ export default {
       dialogList: [],
       realList: [],
       audioElement: null,
+      routepath: ""
     };
   },
   watch: {
-    $route: {
-      handler: function (route) {
-        this.showHeader = route.path === "/login" ? false : true;
+    // $route: {
+    //   handler: function (route) {
+    //     this.showHeader = route.path === "/login" ? false : true;
+    //     this.isShowMenu =
+    //       route.path === "/login" || route.path === "/home" ? false : true;
+    //         // 
+    //   },
+    //   immediate: true,
+    // },
+    $route(to, from) {
+      // 当路由发生变化时,更新 currentPath
+      this.routepath = to.path
+      this.showHeader = to.path === "/login" ? false : true;
         this.isShowMenu =
-          route.path === "/login" || route.path === "/home" ? false : true;
-        this.pagestyFn(route.path)
-      },
-      immediate: true,
-    },
+          to.path === "/login" || to.path === "/home" ? false : true;
+      this.pagestyFn(to.path)
+    }
   },
 
   async created() {
@@ -1447,8 +1456,7 @@ export default {
       return str;
     },
     pagestyFn(path) {
-        let str = "width: 100%;height:100vh";
-    //   let path = window.location.href;
+        let str = "";
         if (path) {
             if (path.indexOf("home") > -1) {
                 str = "width:100%;height:100vh";
@@ -1457,7 +1465,7 @@ export default {
                   if (path.indexOf("generatingCap") > -1) {
                     str = "width: calc(100% - 200px);height:100vh";
                   } else if (path.indexOf("powerPrediction") > -1) {
-                    str = "width: calc(100% - 150px);height:100vh";
+                    str = "width: calc(100% - 160px);height:100vh";
                   } else if (path.indexOf("integratedAlarm") > -1) {
                     str = "width: calc(100% - 300px);height:100vh";
                   }