feat(menu-store): 添加一级菜单活跃状态管理
新增 activeTopMenuPath 状态及相关函数,支持两级菜单结构下的 一级菜单高亮追踪,保持与现有菜单状态的向后兼容。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d1d8558c04
commit
e6350d5e33
1 file changed
+20
-1
@@ -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,
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user