Sfoglia il codice sorgente

topNav自定义隐藏侧边栏路由

RuoYi 4 anni fa
parent
commit
a70d5ee2ab
2 ha cambiato i file con 5 aggiunte e 11 eliminazioni
  1. 4 10
      ruoyi-ui/src/components/TopNav/index.vue
  2. 1 1
      ruoyi-ui/src/layout/index.vue

+ 4 - 10
ruoyi-ui/src/components/TopNav/index.vue

@@ -30,13 +30,14 @@
30
 <script>
30
 <script>
31
 import { constantRoutes } from "@/router";
31
 import { constantRoutes } from "@/router";
32
 
32
 
33
+// 隐藏侧边栏路由
34
+const hideList = ['/index', '/user/profile'];
35
+
33
 export default {
36
 export default {
34
   data() {
37
   data() {
35
     return {
38
     return {
36
       // 顶部栏初始数
39
       // 顶部栏初始数
37
       visibleNumber: 5,
40
       visibleNumber: 5,
38
-      // 是否为首次加载
39
-      isFrist: false,
40
       // 当前激活菜单的 index
41
       // 当前激活菜单的 index
41
       currentIndex: undefined
42
       currentIndex: undefined
42
     };
43
     };
@@ -88,17 +89,10 @@ export default {
88
     activeMenu() {
89
     activeMenu() {
89
       const path = this.$route.path;
90
       const path = this.$route.path;
90
       let activePath = path;
91
       let activePath = path;
91
-      if (path.lastIndexOf("/") > 0) {
92
+      if (path !== undefined && path.lastIndexOf("/") > 0 && hideList.indexOf(path) === -1) {
92
         const tmpPath = path.substring(1, path.length);
93
         const tmpPath = path.substring(1, path.length);
93
         activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
94
         activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
94
         this.$store.dispatch('app/toggleSideBarHide', false);
95
         this.$store.dispatch('app/toggleSideBarHide', false);
95
-      } else if ("/index" == path || "" == path) {
96
-        if (!this.isFrist) {
97
-          this.isFrist = true;
98
-        } else {
99
-          activePath = "index";
100
-        }
101
-        this.$store.dispatch('app/toggleSideBarHide', true);
102
       } else if(!this.$route.children) {
96
       } else if(!this.$route.children) {
103
         activePath = path;
97
         activePath = path;
104
         this.$store.dispatch('app/toggleSideBarHide', true);
98
         this.$store.dispatch('app/toggleSideBarHide', true);

+ 1 - 1
ruoyi-ui/src/layout/index.vue

@@ -102,7 +102,7 @@ export default {
102
   }
102
   }
103
 
103
 
104
   .sidebarHide .fixed-header {
104
   .sidebarHide .fixed-header {
105
-    width: calc(100%);
105
+    width: 100%;
106
   }
106
   }
107
 
107
 
108
   .mobile .fixed-header {
108
   .mobile .fixed-header {