From e6350d5e336acc405fd42b6a128eef87c25f0fed Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Fri, 12 Jun 2026 19:55:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(menu-store):=20=E6=B7=BB=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E7=BA=A7=E8=8F=9C=E5=8D=95=E6=B4=BB=E8=B7=83=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 activeTopMenuPath 状态及相关函数,支持两级菜单结构下的 一级菜单高亮追踪,保持与现有菜单状态的向后兼容。 Co-authored-by: Cursor --- web-admin/src/store/modules/menu.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/web-admin/src/store/modules/menu.ts b/web-admin/src/store/modules/menu.ts index 23b205ad..24a5c003 100755 --- a/web-admin/src/store/modules/menu.ts +++ b/web-admin/src/store/modules/menu.ts @@ -47,6 +47,8 @@ export const useMenuStore = defineStore('menuStore', () => { const menuWidth = ref('') /** 存储路由移除函数的数组 */ const removeRouteFns = ref<(() => void)[]>([]) + /** 活跃的一级菜单路径 */ + const activeTopMenuPath = ref('') /** * 设置菜单列表 @@ -95,15 +97,32 @@ export const useMenuStore = defineStore('menuStore', () => { removeRouteFns.value = [] } + /** + * 设置活跃一级菜单路径 + * @param path 菜单路径 + */ + const setActiveTopMenuPath = (path: string) => { + activeTopMenuPath.value = path + } + + /** + * 获取活跃一级菜单路径 + * @returns 菜单路径字符串 + */ + const getActiveTopMenuPath = () => activeTopMenuPath.value + return { menuList, menuWidth, removeRouteFns, + activeTopMenuPath, setMenuList, getHomePath, setHomePath, addRemoveRouteFns, removeAllDynamicRoutes, - clearRemoveRouteFns + clearRemoveRouteFns, + setActiveTopMenuPath, + getActiveTopMenuPath, } })