diff --git a/src/layouts/MixLayout.vue b/src/layouts/MixLayout.vue index 09f31fcb..b47357ff 100644 --- a/src/layouts/MixLayout.vue +++ b/src/layouts/MixLayout.vue @@ -207,8 +207,15 @@ watch( () => route.path, (newPath) => { const topMenuPath = extractTopMenuPath(newPath); - if (topMenuPath !== activeTopMenuPath.value) { + const isTopMenuChanged = topMenuPath !== activeTopMenuPath.value; + + if (isTopMenuChanged) { appStore.activeTopMenu(topMenuPath); + } + + // 切换布局(如左侧 -> 混合)时,activeTopMenuPath 可能已是正确值, + // 但 mixLayoutSideMenus 仍为空,需要补一次初始化。 + if (isTopMenuChanged || permissionStore.mixLayoutSideMenus.length === 0) { permissionStore.setMixLayoutSideMenus(topMenuPath); } },