Skip to content

Commit

Permalink
Merge branch 'main' of github.com:arco-design/arco-design-pro-vue
Browse files Browse the repository at this point in the history
  • Loading branch information
sHow8e committed May 31, 2022
2 parents d1ae928 + d3447c7 commit 00a3c7b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions arco-design-pro-vite/src/components/menu/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
},
});
const openKeys = ref<string[]>([]);
const selectedKey = ref<string[]>([]);
const goto = (item: RouteRecordRaw) => {
if (regexUrl.test(item.path)) {
Expand All @@ -37,11 +39,17 @@
};
listenerRouteChange((newRoute) => {
if (newRoute.meta.requiresAuth && !newRoute.meta.hideInMenu) {
const { matched } = newRoute;
if (matched.length > 1) {
matched.slice(0, matched.length - 1).forEach(({ name }) => {
if (!openKeys.value.includes(name as string))
openKeys.value.push(name as string);
});
}
if (newRoute.meta.activeMenu) {
selectedKey.value = [newRoute.meta.activeMenu];
} else {
const key = newRoute.matched[newRoute.matched.length - 1]
?.name as string;
const key = matched[matched.length - 1]?.name as string;
selectedKey.value = [key];
}
}
Expand Down Expand Up @@ -90,6 +98,7 @@
return () => (
<a-menu
v-model:collapsed={collapsed.value}
v-model:open-keys={openKeys.value}
show-collapse-button={appStore.device !== 'mobile'}
auto-open={false}
selected-keys={selectedKey.value}
Expand Down

0 comments on commit 00a3c7b

Please sign in to comment.