Skip to content

Commit

Permalink
Update App.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Jun 13, 2024
1 parent 239a3b4 commit db27ed2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,20 @@ const items = ref([
}
]);
let hrefs = window.location.href.split('/');
let temp: any = '';
let keys: string[] = [];
hrefs.pop()
while (temp !== '#') {
temp = hrefs.pop();
if (temp !== '#') keys.push(temp);
}
const state = reactive({
collapsed: false,
selectedKeys: [window.location.href.split('/').pop() || 'home']
selectedKeys: [window.location.href.split('/').pop() || 'home'],
openKeys: keys,
});
function toggleCollapsed() {
Expand All @@ -77,6 +88,7 @@ function select(page: any) {
}
path = path === '/home' ? '/' : path;
router.push(path);
console.log(state);
}
</script>

Expand Down Expand Up @@ -108,6 +120,7 @@ function select(page: any) {
<a-layout-sider class="app-sider" :collapsed="state.collapsed" :trigger="null" collapsible>
<a-menu
v-model:selectedKeys="state.selectedKeys"
v-model:open-keys="state.openKeys"
mode="inline"
class="app-menu"
:items="items"
Expand Down

0 comments on commit db27ed2

Please sign in to comment.