Browse Source

去除菜单栏相关监听

杨宽 3 years ago
parent
commit
86bcb0e939
2 changed files with 67 additions and 94 deletions
  1. 29 30
      src/views/layout/Header.vue
  2. 38 64
      src/views/layout/Menu.vue

+ 29 - 30
src/views/layout/Header.vue

@@ -5,8 +5,7 @@
         {{ menu.text }}
       </li>
     </ul>
-    <!--
-    <ul class="header-menu-dropdown" :class="{ dropdown: dropdown }">
+    <!-- <ul class="header-menu-dropdown" :class="{ dropdown: dropdown }">
       <li class="header-menu-dropdown-title" @click="clickMenu()"><i class="fa fa-gear"></i>菜单<i class="fa fa-sort-down down"></i></li>
       <ul class="header-menu-dropdown-list">
         <li class="header-menu-dropdown-item" v-for="(menu, index) of menusDropdown" :key="menu" @click="clickSubMenu(index, menu.code)">
@@ -68,21 +67,21 @@ export default {
         },
       ],
       activeIndex: 0,
-      /* menusDropdown: [
-        {
-          text: "子菜单1",
-          code: "submenu1",
-        },
-        {
-          text: "子菜单2",
-          code: "submenu2",
-        },
-        {
-          text: "子菜单3",
-          code: "submenu3",
-        },
-      ],
-      dropdown: false,*/
+      // menusDropdown: [
+      //   {
+      //     text: "子菜单1",
+      //     code: "submenu1",
+      //   },
+      //   {
+      //     text: "子菜单2",
+      //     code: "submenu2",
+      //   },
+      //   {
+      //     text: "子菜单3",
+      //     code: "submenu3",
+      //   },
+      // ],
+      // dropdown: false,
     };
   },
   emits: {
@@ -105,19 +104,19 @@ export default {
       return data.isActive ? "active" : "";
     },
   },
-  watch: {
-    $route: {
-      handler: function(val, oldVal) {
-        this.menus.some((t, index) => {
-          if (t.id == val.query.root) {
-            this.activeIndex = index;
-          }
-        });
-      },
-      //深度观察监听
-      deep: true,
-    },
-  },
+  // watch: {
+  //   $route: {
+  //     handler: function(val, oldVal) {
+  //       this.menus.some((t, index) => {
+  //         if (t.id == val.query.root) {
+  //           this.activeIndex = index;
+  //         }
+  //       });
+  //     },
+  //     //深度观察监听
+  //     deep: true,
+  //   },
+  // },
 };
 </script>
 

+ 38 - 64
src/views/layout/Menu.vue

@@ -82,38 +82,12 @@ export default {
               icon: "svg-agc",
               path: "/agc",
             },
-            /*   {
-              text: "网络",
-              icon: "svg-agc",
-              path: "/agc",
-            },
-            {
-              text: "风场",
-              icon: "svg-wind-site",
-              path: "/windsite/home",
-            },
-            {
-              text: "关于",
-              icon: "svg-agc",
-              path: "/about",
-            },*/
           ],
         },
         {
           id: "datacenter",
           text: "数据管理",
-          data: [
-            /*{
-              text: "矩阵",
-              icon: "svg-matrix",
-              path: "/lightmatrix",
-            },
-            {
-              text: "矩阵",
-              icon: "svg-matrix",
-              path: "/lightmatrix1",
-            },*/
-          ],
+          data: [],
         },
         {
           id: "statistic",
@@ -128,7 +102,7 @@ export default {
               text: "健康管理1",
               icon: "svg-wind-site",
               path: "/health1",
-            }/*,
+            },
             {
               text: "健康管理2",
               icon: "svg-wind-site",
@@ -158,7 +132,7 @@ export default {
               text: "健康管理7",
               icon: "svg-wind-site",
               path: "/health7",
-            },*/
+            },
           ],
         },
         {
@@ -169,22 +143,22 @@ export default {
               text: "决策支持1",
               icon: "svg-matrix",
               path: "/decision1",
-            },/*
-            {
-              text: "决策支持2",
-              icon: "svg-matrix",
-              path: "/decision2",
-            },
-            {
-              text: "决策支持3",
-              icon: "svg-matrix",
-              path: "/decision3",
             },
-            {
-              text: "决策支持4",
-              icon: "svg-matrix",
-              path: "/decision4",
-            },*/
+            // {
+            //   text: "决策支持2",
+            //   icon: "svg-matrix",
+            //   path: "/decision2",
+            // },
+            // {
+            //   text: "决策支持3",
+            //   icon: "svg-matrix",
+            //   path: "/decision3",
+            // },
+            // {
+            //   text: "决策支持4",
+            //   icon: "svg-matrix",
+            //   path: "/decision4",
+            // },
           ],
         },
         {
@@ -236,20 +210,20 @@ export default {
   },
   watch: {
     //监听路由
-    $route: {
-      handler: function(val, oldVal) {
-        if (val.query.root) this.currRoot = val.query.root;
+    // $route: {
+    //   handler: function(val, oldVal) {
+    //     if (val.query.root) this.currRoot = val.query.root;
 
-        this.currentMenu.some((element, index) => {
-          if (element.path == val.path) {
-            this.activeIndex = index;
-            return true;
-          }
-        });
-      },
-      //深度观察监听
-      deep: true,
-    },
+    //     this.currentMenu.some((element, index) => {
+    //       if (element.path == val.path) {
+    //         this.activeIndex = index;
+    //         return true;
+    //       }
+    //     });
+    //   },
+    //   //深度观察监听
+    //   deep: true,
+    // },
     root: {
       handler: function(val, oldVal) {
         this.currRoot = val;
@@ -261,13 +235,13 @@ export default {
           // 基于 root 和 currRoot 为一致
           // 进行页面刷新
           // 防止 刷新页面也同步执行切换页面逻辑
-          if (this.root == this.currRoot) {
-            this.activeIndex = 0;
-            this.$router.push({
-              path: val[0].path,
-              query: { root: this.currRoot },
-            });
-          }
+          // if (this.root == this.currRoot) {
+          // this.activeIndex = 0;
+          // this.$router.push({
+          //   path: val[0].path,
+          //   query: { root: this.currRoot },
+          // });
+          // }
         }
       },
     },