Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(menu-list): 修复 左侧菜单全部展开后看不到全部菜单 #89 #99

Closed
wants to merge 12 commits into from
70 changes: 51 additions & 19 deletions src/layouts/default/sidebar/components/Menu.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
<template>
<a-menu
v-model:openKeys="openKeys"
v-model:selectedKeys="selectedKeys"
mode="inline" theme="dark"
:inline-collapsed="getCollapsed"
>
<template v-for="menu in menus" :key="menu.path">
<menu-item
v-if="menu.meta?.single"
:menu="menu"
/>
<menu-with-children
v-else
:current-depth="1"
:parent-path="menu.path"
:menu="menu"
/>
</template>
</a-menu>
<div>
<a-menu
v-model:openKeys="openKeys"
v-model:selectedKeys="selectedKeys"
:class="getMenuClass"
mode="inline" theme="dark"
:inline-collapsed="getCollapsed"
>
<template v-for="menu in menus" :key="menu.path">
<menu-item
v-if="menu.meta?.single"
:menu="menu"
/>
<menu-with-children
v-else
:current-depth="1"
:parent-path="menu.path"
:menu="menu"
/>
</template>
</a-menu>
</div>
</template>
<script setup lang="ts">
import MenuWithChildren from './MenuWithChildren.vue'
Expand Down Expand Up @@ -70,4 +73,33 @@ function getCurrentMenuRecursive(menus: RouteModuleList, targetKey: string, pare
}
return keys
}

const getMenuClass = computed(() => {
return ['menu-class', 'menu-class--fixed']
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不需要用computed属性

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没看明白这个 computed 存在的意义

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是 参照 /src/layouts/default/sidebar/index.vue 的写法。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sidebar/index.vue 是想后面做扩展哈哈~

</script>

<style scoped lang="less">
:deep(.menu-class) {
&--fixed {
height: calc(100vh - 56px);
overflow-y: auto;
}
}

/*定义整个滚动条高宽及背景:高宽分别对应横竖滚动条的尺寸*/
:deep(::-webkit-scrollbar) {
width: 2px;
height: 2px;
background-color: #F5F5F5;
}
/*定义滚动条轨道:内阴影+圆角*/
:deep(::-webkit-scrollbar-track) {
background-color: #F5F5F5;
}
/*定义滑块:内阴影+圆角*/
:deep(::-webkit-scrollbar-thumb) {
border-radius: 2px;
background-color: rgb(119, 119, 119);
}
</style>