From 138af65d0cc7eb1c938823a7537c0715992f6e0d Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Thu, 25 Jan 2024 11:40:48 +0800 Subject: [PATCH] refactor: improve effect of menu expand (#5244) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /area console /milestone 2.12.x /kind improvement #### What this PR does / why we need it: 优化 Console 左侧菜单的展开逻辑,改为可以通过点击展开图标来展开子菜单。 image #### Does this PR introduce a user-facing change? ```release-note 优化 Console 左侧菜单的展开逻辑,支持通过点击图标来展开子菜单。 ``` --- .../src/components/menu/MenuItem.vue | 20 +++++++++++++---- .../components/menu/__tests__/Menu.spec.tsx | 15 +++++++++---- .../__snapshots__/Menu.spec.tsx.snap | 22 +++++++++---------- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/console/packages/components/src/components/menu/MenuItem.vue b/console/packages/components/src/components/menu/MenuItem.vue index 6d85d811f0..a4ed9b2095 100644 --- a/console/packages/components/src/components/menu/MenuItem.vue +++ b/console/packages/components/src/components/menu/MenuItem.vue @@ -34,17 +34,23 @@ const hasSubmenus = computed(() => { }); function handleClick() { + if (!open.value) { + handleExpand(); + } + emit("select", props.id); +} + +function handleExpand() { if (hasSubmenus.value) { open.value = !open.value; } - emit("select", props.id); }