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, } })