refactor(menu): simplify menu active state synchronization logic

- Streamlined the synchronization of the active menu state by reducing multiple calls to syncMenuActive to a single call within nextTick.
- Added a comment to clarify the rationale behind the change and potential fallback options for synchronization issues.
This commit is contained in:
zhangtao
2026-03-29 20:36:48 +08:00
parent 7081850d46
commit c5ec09f06f
2 changed files with 7 additions and 12 deletions
@@ -107,17 +107,11 @@ function syncMenuActive(val: string) {
menuRef.value?.updateActiveIndex(val);
}
// 仅 nextTick 一次同步;若侧栏 default-active 偶发与路由不同步,可恢复为多次 syncMenuActive(见本文件 git 历史)
watch(
activeMenuPath,
(val) => {
nextTick(() => {
syncMenuActive(val);
requestAnimationFrame(() => {
syncMenuActive(val);
setTimeout(() => syncMenuActive(val), 0);
setTimeout(() => syncMenuActive(val), 50);
});
});
nextTick(() => syncMenuActive(val));
},
{ immediate: true, flush: "post" }
);