index.vue
3.63 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//个人中心侧边栏
<template>
<div class="HtPerSideBar">
<template v-for="(route, i) in perList">
<div
class="item_content"
@click="handleSelect(route)"
:class="active == route.alias ? 'item_content_active' : ''"
>
{{ route.meta.title }}
</div>
</template>
</div>
</template>
<script>
import variables from '@/styles/variables.scss'
import { mapGetters } from 'vuex'
export default {
data() {
return {
perList: [],
defaultPerMun: ['security', 'information', 'Setting'],
newRoutes: [],
information: {
alias: 'information',
type: 'page',
path: '/personal/information',
meta: {
isChildren: true,
menuLevel: 'first',
title: '个人信息',
},
},
active: '',
}
},
mounted() {
let li = []
this.newRoutes = _.cloneDeep(
this.routes.filter((item) => {
return item.path.indexOf('/personal') > -1
})
)
if (
this.newRoutes &&
this.newRoutes[0] &&
this.newRoutes[0].children &&
this.newRoutes[0].children.length > 0
) {
this.newRoutes[0].children.forEach((item) => {
this.defaultPerMun.forEach((its) => {
if (item.alias == its) {
li.push(item)
}
})
})
this.perList = li
this.perList.forEach((item) => {
item.path = '/personal/' + item.alias.toLowerCase()
})
}
//添加个人信息
this.perList.some((item) => {
return item.alias == 'information'
})
? ''
: this.perList.unshift(this.information)
if (this.perList.length > 0) {
this.handleSelect(this.perList[0])
}
this.$emit('perList', this.perList)
},
computed: {
...mapGetters({
collapse: 'settings/collapse',
style: 'settings/style',
routes: 'routes/routes',
themeColor: 'settings/themeColor',
}),
activeMenu() {
const route = this.$route
const { meta, path } = route
if (meta.activeMenu) {
return meta.activeMenu
}
return path
},
variables() {
return variables
},
},
methods: {
handleSelect(key) {
this.active = key.alias
this.$emit('alis', key.alias)
},
},
}
</script>
<style lang="scss" scoped>
.HtPerSideBar {
margin-right: 16px;
width: 200px;
border-radius: 12px 12px 12px 12px;
height: calc(100% - 48px);
padding: 24px 8px;
border-radius: 12px;
border-right: none;
background: $base-color-white !important;
::v-deep {
.el-menu {
margin: 24px 8px;
border-radius: 12px;
border-right: none;
.el-menu-item {
height: 48px;
display: flex;
justify-content: flex-start;
align-items: center;
}
.is-active {
background: #ebf5ff !important;
border-radius: 8px 8px 8px 8px;
&:hover {
background: #ebf5ff !important;
}
}
}
}
}
.item_content {
height: 48px;
display: flex;
justify-content: flex-start;
align-items: center;
line-height: 56px;
font-size: 14px;
padding: 0 20px;
list-style: none;
cursor: pointer;
position: relative;
box-sizing: border-box;
white-space: nowrap;
margin: 0;
}
.item_content_active {
border-radius: 8px 8px 8px 8px;
color: var(--themeColor) !important;
background: #ebf5ff !important;
}
</style>