From 7d43be051e66e211fde7d060dcabdac2bc373673 Mon Sep 17 00:00:00 2001 From: From-wh Date: Thu, 23 Feb 2023 14:22:52 +0800 Subject: [PATCH] =?UTF-8?q?improve:=20=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/components/side-menu/side-menu.vue | 24 ++++++++++++------- template/admin/src/components/main/main.vue | 1 - 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/template/admin/src/components/main/components/side-menu/side-menu.vue b/template/admin/src/components/main/components/side-menu/side-menu.vue index 21adadeb0..07de96187 100644 --- a/template/admin/src/components/main/components/side-menu/side-menu.vue +++ b/template/admin/src/components/main/components/side-menu/side-menu.vue @@ -170,6 +170,15 @@ export default { this.$refs.menu.updateOpened(); }); }, + collapsed(val) { + if (!val) { + console.log(this.$route, this.findParentById(this.menuList, this.$route.path)); + this.handleSelect(this.findParentById(this.menuList, this.$route.path)); + this.$nextTick(() => { + this.$refs.childMenu.updateOpened(); + }); + } + }, $route(newRoute) {}, $route: { handler(newRoute) { @@ -189,9 +198,9 @@ export default { console.log(this.menuList); this.openedNames = getUnion(this.openedNames, this.getOpenedNamesByActiveName()); if (sessionStorage.getItem('menuActive')) { - // this.activeMenuPath = sessionStorage.getItem('menuActive'); - // this.catName = sessionStorage.getItem('menuActiveTitle'); - // this.getChildrenList(sessionStorage.getItem('menuActive')); + this.activeMenuPath = sessionStorage.getItem('menuActive'); + this.catName = sessionStorage.getItem('menuActiveTitle'); + this.getChildrenList(sessionStorage.getItem('menuActive')); } else { this.handleSelect(this.openedNames[0]); } @@ -256,11 +265,12 @@ export default { this.turnToPage(name); }, collHandleSelect(name) { + console.log(this.menuList) this.activeMenuPath = this.findParentById(this.menuList, name); this.turnToPage(name); }, findParentById(arr, path) { - var parentId = '没有父元素', + var parentId = '', hasParentId = (function loop(arr) { return arr.some((item) => { if (item.path === path) { @@ -338,7 +348,6 @@ export default {