作者 RuoYi

topNav自定义隐藏侧边栏路由

@@ -30,13 +30,14 @@ @@ -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,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);