LeftSideMenuLv1Item.vue
2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<template>
<div :class="['com-left-side-menu-lv1-item', isActive]" @mouseenter.stop="mouseenter" @mouseleave.stop="mouseleave" @click.stop="handleClick()">
<i :class="['i', icon]"></i>
<span class="title">{{ menuData.title }}</span>
</div>
</template>
<script>
import { mapActions, mapGetters } from 'vuex'
// import { utils } from 'glsx-common'
import { currentId } from './mixins/index'
export default {
name: 'LeftSideMenuLv1Item',
inject: ['bus'],
mixins: [currentId],
props: {
menuData: {
type: Object,
default: () => {}
}
},
computed: {
...mapGetters(['app', 'menu']),
icon() {
return `i-${this.menuData.icon}${['', '-active'][+this.isHighlight]}`
},
isHighlight() {
return this.app?.currentPage?.id?.split('-')[0] == this.menuData.id
},
isActive() {
if (this.isHighlight) {
return 'highlight'
} else if (this.menu.hoverId == this.menuData.id) {
return 'hover'
}
return ''
}
},
methods: {
mouseenter: function (e) {
this.setHoverId(this.menuData.id)
this.menu.isCollapse && this.bus.$emit('mouseenter', e.target, this.emitter)
},
mouseleave: function () {
this.setHoverId('')
},
handleClick() {
!this.menu.isCollapse && this.emitter()
},
emitter() {
this.bus.$emit('menuChanged', { menus: this.menuData.children?.noHidden() })
},
...mapActions('menu', ['setHoverId'])
}
}
</script>
<style lang="scss" scoped>
@import '~@/assets/style/collapse.scss';
.com-left-side-menu-lv1-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: $menu_width_collapse;
height: 46px;
gap: 4px;
cursor: pointer;
&.highlight {
background-color: #edecff;
.title {
color: $main-color;
}
}
&.hover {
background-color: #f0f1f7;
}
.title {
font-size: 10px;
color: #666;
// transform: scale(0.9);
overflow: hidden;
// text-overflow: ellipsis;
// white-space: nowrap;
// max-width: 5em;
// user-select: none;
}
}
</style>