mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-04 17:14:21 +00:00
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:
@@ -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" }
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user