From ed79e81b13df880edcd25b3e22553423b9bc2d98 Mon Sep 17 00:00:00 2001 From: zclzone Date: Fri, 25 Nov 2022 09:16:01 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=88=87=E6=8D=A2tab=E6=97=B6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=B1=95=E5=BC=80=E5=AF=B9=E5=BA=94=E7=9A=84=E8=8F=9C?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/sidebar/components/SideMenu.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/layout/components/sidebar/components/SideMenu.vue b/src/layout/components/sidebar/components/SideMenu.vue index 3c36a5a..717fe9d 100644 --- a/src/layout/components/sidebar/components/SideMenu.vue +++ b/src/layout/components/sidebar/components/SideMenu.vue @@ -1,12 +1,13 @@ @@ -20,10 +21,18 @@ const curRoute = useRoute() const permissionStore = usePermissionStore() const appStore = useAppStore() +const activeKey = computed(() => curRoute.meta?.activeMenu || curRoute.name) + const menuOptions = computed(() => { return permissionStore.menus.map((item) => getMenuItem(item)).sort((a, b) => a.order - b.order) }) +const menu = ref(null) +watch(curRoute, async () => { + await nextTick() + menu.value?.showOption() +}) + function resolvePath(basePath, path) { if (isExternal(path)) return path return ( @@ -52,11 +61,11 @@ function getMenuItem(route, basePath = '') { // 单个子路由处理 const singleRoute = visibleChildren[0] menuItem = { + ...menuItem, label: singleRoute.meta?.title || singleRoute.name, key: singleRoute.name, path: resolvePath(menuItem.path, singleRoute.path), icon: getIcon(singleRoute.meta), - order: menuItem.order, } const visibleItems = singleRoute.children ? singleRoute.children.filter((item) => item.name && !item.isHidden) : [] @@ -70,7 +79,6 @@ function getMenuItem(route, basePath = '') { .map((item) => getMenuItem(item, menuItem.path)) .sort((a, b) => a.order - b.order) } - return menuItem }