Skip to content

Commit d6825a8

Browse files
authored
fix(sidebar): 首页在左侧菜单缩小模式下,选择菜单,样式出错 (#389)
1 parent e8900bc commit d6825a8

4 files changed

Lines changed: 34 additions & 97 deletions

File tree

src/assets/style/realize/element-variable.scss

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -410,45 +410,6 @@ thead tr {
410410
top: 23px;
411411
}
412412
}
413-
414-
&.third {
415-
416-
// 3级
417-
.el-menu-item {
418-
position: relative;
419-
420-
&:before {
421-
content: "";
422-
width: 4px;
423-
height: 4px;
424-
border-radius: 50%;
425-
border: 1px solid $submenu-title;
426-
position: absolute;
427-
left: 65px;
428-
top: 23px;
429-
}
430-
}
431-
432-
.el-menu-item-group__title {
433-
padding: 0;
434-
}
435-
436-
.el-menu-item.is-active {
437-
position: relative;
438-
439-
&:before {
440-
content: "";
441-
width: 6px;
442-
height: 6px;
443-
border-radius: 50%;
444-
border: none;
445-
background: $theme;
446-
position: absolute;
447-
left: 65px;
448-
top: 23px;
449-
}
450-
}
451-
}
452413
}
453414
}
454415

@@ -457,8 +418,9 @@ thead tr {
457418
border-right: 1px solid #1d2a60;
458419
}
459420

460-
.el-menu--vertical .abc {
461-
left: 70px !important;
421+
.el-menu--vertical > .el-menu--popup {
422+
max-height: 100vh;
423+
overflow-y: auto;
462424
}
463425

464426
.el-menu--vertical >>> .icon-erjizhibiao {

src/component/layout/sidebar/menu-content.vue

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/component/layout/sidebar/menu-tree.vue

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
<template>
2-
<el-submenu
3-
v-if="item.children && item.children.length > 0"
4-
class="sub-menu-content"
5-
:index="item.path"
6-
popper-class="abc"
7-
>
2+
<el-submenu v-if="item.children && item.children.length > 0" :index="item.path" popper-append-to-body>
83
<template #title>
9-
<menu-content :icon="item.icon" :title="item.title" />
4+
<i v-if="!filterIcon(item.icon)" :class="item.icon"></i>
5+
<img v-else :src="item.icon" class="img-icon" />
6+
<span>{{ item.title }}</span>
107
</template>
118
<menu-tree v-for="child in item.children" :key="child.path" :item="child" />
129
</el-submenu>
1310

14-
<el-menu-item v-else class="sub-menu-content" :index="item.path" @click="navigateTo(item.path)">
15-
<menu-content :icon="item.icon" :title="item.title" />
11+
<el-menu-item v-else :index="item.path" @click="navigateTo(item.path)">
12+
<i v-if="!filterIcon(item.icon)" :class="item.icon"></i>
13+
<img v-else :src="item.icon" class="img-icon" />
14+
<template #title
15+
><span class="title">{{ item.title }}</span></template
16+
>
1617
</el-menu-item>
1718
</template>
1819

1920
<script>
20-
import MenuContent from './menu-content'
21-
2221
export default {
2322
name: 'MenuTree',
24-
components: { MenuContent },
2523
props: {
2624
item: {
2725
type: Object,
@@ -33,12 +31,31 @@ export default {
3331
navigateTo(path) {
3432
this.$router.push({ path })
3533
},
34+
filterIcon(icon) {
35+
return icon.indexOf('/') !== -1
36+
},
3637
},
3738
}
3839
</script>
3940

4041
<style lang="scss" scoped>
41-
.sub-menu-content {
42+
.img-icon {
43+
width: 16px;
44+
height: 16px;
45+
margin-right: 10px;
46+
margin-left: 5px;
47+
display: inline-block;
48+
transform: translateY(21px);
49+
}
50+
.iconfont {
51+
margin-right: 10px;
52+
margin-left: 5px;
53+
color: $submenu-title;
54+
height: $menuItem-height;
55+
}
56+
.title {
57+
display: inline-block;
58+
width: 110px;
4259
overflow: hidden;
4360
text-overflow: ellipsis;
4461
white-space: nowrap;

src/config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const Config = {
2-
sidebarLevel: 3, // 侧边栏层级限制, 3 表示三级, 可设置 2 和 3
2+
sidebarLevel: 3, // 侧边栏层级(无限级)限制, 默认为 3 级,可根据需求自行扩充
33
openAutoJumpOut: true, // 是否开启无操作跳出
44
defaultRoute: '/about', // 默认打开的路由
55
showSidebarSearch: true, // 默认打开侧边栏搜索

0 commit comments

Comments
 (0)