补充页面

This commit is contained in:
2026-02-11 20:16:51 +08:00
parent 53820a4654
commit db9c4da279
12 changed files with 1326 additions and 248 deletions

View File

@@ -92,8 +92,20 @@ function isActive(node: MenuNode): boolean {
// 只有非分组项才能被视为“激活”变色 (1:1 复刻 screenshot 效果)
if (node.type === 'group') return false
if (props.activeId != '' && node.id === props.activeId) return true
if (props.currentPath != '' && node.path === props.currentPath) return true
// 核心逻辑:优先匹配 IDID 是唯一的
// 如果当前选中的 ID 就是这个节点的 ID那它肯定是激活的
if (props.activeId != '' && node.id === props.activeId) {
return true
}
// 如果 ID 没匹配上,但路径匹配上了,且当前没有 activeId (例如首次进入或刷新)
// 或者当前 ID 对应的路径跟这个路径一样
// 但为了防止 Path 相同导致多选,我们加一个额外判断:
// 如果 activeId 已经指向了一个有效的路由,我们通常不再通过 Path 来高亮其他项
if (props.activeId === '' && props.currentPath != '' && node.path === props.currentPath) {
return true
}
return false
}