menus.vue
1.19 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
<template>
<Menu theme="dark" width="auto" :open-names="['product']" @on-select="open" :active-name="activeName">
<div class="layout-logo-left"></div>
<Submenu :name="key" v-for="(purview, key) in purviews" :key="key" v-if="purview.menu">
<template slot="title">
<Icon type="ios-navigate"></Icon>
{{purview.name}}
</template>
<Menu-item :name="`${key}.${subKey}`" v-for="(subPurview, subKey) in purview.subPurviews" v-if="subPurview.menu" :key="subKey">{{subPurview.name}}</Menu-item>
</Submenu>
</Menu>
</template>
<script>
import _ from 'lodash';
export default {
name: 'purview-menu',
data() {
return {
purviews: this.$config.purviews, // TODO 根据用户权限,初始化菜单
activeName: ''
};
},
created() {
this.activeName = this.$router.history.current.name;
},
methods: {
open(menuName) {
let menu = _.get(this.purviews, menuName.replace('.', '.subPurviews.'));
if (menu) {
this.$router.push(menu.path);
}
}
}
};
</script>
<style lang="scss">
</style>