提交 6d5c49f0 作者: vben

fix(menu): currentActiveMenu fails after refresh #188

上级 0aeec5e9
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
emits: ['menuClick'], emits: ['menuClick'],
setup(props, { emit }) { setup(props, { emit }) {
const isClickGo = ref(false); const isClickGo = ref(false);
const currentActiveMenu = ref('');
const menuState = reactive<MenuState>({ const menuState = reactive<MenuState>({
defaultSelectedKeys: [], defaultSelectedKeys: [],
...@@ -118,10 +119,11 @@ ...@@ -118,10 +119,11 @@
listenerLastChangeTab((route) => { listenerLastChangeTab((route) => {
if (route.name === REDIRECT_NAME) return; if (route.name === REDIRECT_NAME) return;
handleMenuChange(route); handleMenuChange(route);
const currentActiveMenu = route.meta?.currentActiveMenu; currentActiveMenu.value = route.meta?.currentActiveMenu;
if (currentActiveMenu) {
menuState.selectedKeys = [currentActiveMenu]; if (unref(currentActiveMenu)) {
setOpenKeys(currentActiveMenu); menuState.selectedKeys = [unref(currentActiveMenu)];
setOpenKeys(unref(currentActiveMenu));
} }
}); });
...@@ -153,6 +155,7 @@ ...@@ -153,6 +155,7 @@
} }
const path = (route || unref(currentRoute)).path; const path = (route || unref(currentRoute)).path;
setOpenKeys(path); setOpenKeys(path);
if (unref(currentActiveMenu)) return;
if (props.isHorizontal && unref(getSplit)) { if (props.isHorizontal && unref(getSplit)) {
const parentPath = await getCurrentParentPath(path); const parentPath = await getCurrentParentPath(path);
menuState.selectedKeys = [parentPath]; menuState.selectedKeys = [parentPath];
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论