|
@@ -1,48 +1,35 @@
|
|
<template>
|
|
<template>
|
|
<div id="admin-menu" style="background-color: rgb(0, 20, 42);">
|
|
<div id="admin-menu" style="background-color: rgb(0, 20, 42);">
|
|
- <scroll-bar>
|
|
|
|
- <div class="logo">
|
|
|
|
- <img src="https://img.alicdn.com/tfs/TB13UQpnYGYBuNjy0FoXXciBFXa-242-134.png" width="40" />
|
|
|
|
- <span class="site-name">ADMIN LITE</span>
|
|
|
|
- </div>
|
|
|
|
- <el-menu
|
|
|
|
- mode="vertical"
|
|
|
|
- :show-timeout="200"
|
|
|
|
- background-color="#00142a"
|
|
|
|
- text-color="hsla(0, 0%, 100%, .65)"
|
|
|
|
- active-text-color="#409EFF"
|
|
|
|
- :unique-opened="true"
|
|
|
|
- >
|
|
|
|
- <span v-for="(item, index) in menu" :key="index">
|
|
|
|
- <!-- <span v-if="`${item.role}` === `${user.role}` || !item.role"> -->
|
|
|
|
- <!-- v-if="`${item.role}` === `${user.role}`" -->
|
|
|
|
- <span v-if="!item.children" :to="item.path" :key="item.name">
|
|
|
|
- <el-menu-item :index="item.path" @click="selectMenu(item.path, item.module)">
|
|
|
|
- <i v-if="item.icon" :class="item.icon"></i>
|
|
|
|
- <span v-if="item.name" slot="title">{{ item.name }}</span>
|
|
|
|
- </el-menu-item>
|
|
|
|
- </span>
|
|
|
|
-
|
|
|
|
- <el-submenu v-else :index="item.name || item.path" :key="item.name">
|
|
|
|
- <template slot="title">
|
|
|
|
- <i v-if="item && item.icon" :class="item.icon"></i>
|
|
|
|
- <span v-if="item && item.name" slot="title">{{ item.name }}</span>
|
|
|
|
- </template>
|
|
|
|
- <template v-for="(child, childIndex) in item.children">
|
|
|
|
- <div :key="childIndex" v-if="!child.hidden">
|
|
|
|
- <el-menu-item :index="item.path + child.path" @click="selectMenu(item.path + child.path, item.module)">
|
|
|
|
- <span v-if="child && child.name" slot="title">{{ child.name }}</span>
|
|
|
|
- </el-menu-item>
|
|
|
|
- </div>
|
|
|
|
- </template>
|
|
|
|
- </el-submenu>
|
|
|
|
- </span>
|
|
|
|
- </el-menu>
|
|
|
|
- </scroll-bar>
|
|
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <div class="logo">
|
|
|
|
+ <img src="https://img.alicdn.com/tfs/TB13UQpnYGYBuNjy0FoXXciBFXa-242-134.png" width="40" />
|
|
|
|
+ <span class="site-name">ADMIN LITE</span>
|
|
|
|
+ </div>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <template>
|
|
|
|
+ <el-menu
|
|
|
|
+ mode="vertical"
|
|
|
|
+ :show-timeout="200"
|
|
|
|
+ background-color="#00142a"
|
|
|
|
+ text-color="hsla(0, 0%, 100%, .65)"
|
|
|
|
+ active-text-color="#409EFF"
|
|
|
|
+ :unique-opened="true"
|
|
|
|
+ :default-active="defualtActive"
|
|
|
|
+ >
|
|
|
|
+ <scroll-bar>
|
|
|
|
+ <menu-item :menus="menu"></menu-item>
|
|
|
|
+ </scroll-bar>
|
|
|
|
+ </el-menu>
|
|
|
|
+ </template>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+import menuItem from './menu/menu-item.vue';
|
|
import * as menus from '@frame/config/menu-config';
|
|
import * as menus from '@frame/config/menu-config';
|
|
import scrollBar from './scrollBar.vue';
|
|
import scrollBar from './scrollBar.vue';
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
@@ -51,6 +38,7 @@ export default {
|
|
props: {},
|
|
props: {},
|
|
components: {
|
|
components: {
|
|
scrollBar,
|
|
scrollBar,
|
|
|
|
+ menuItem,
|
|
},
|
|
},
|
|
data: () => ({
|
|
data: () => ({
|
|
menu: [],
|
|
menu: [],
|
|
@@ -60,15 +48,34 @@ export default {
|
|
project_modules() {
|
|
project_modules() {
|
|
return process.env.VUE_APP_MODULE;
|
|
return process.env.VUE_APP_MODULE;
|
|
},
|
|
},
|
|
|
|
+ defualtActive() {
|
|
|
|
+ return this.$route.path;
|
|
|
|
+ },
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
let arr = _.get(menus, this.project_modules, []);
|
|
let arr = _.get(menus, this.project_modules, []);
|
|
- this.$set(this, `menu`, arr);
|
|
|
|
|
|
+ let r = this.filterMenu(_.cloneDeep(arr), this.project_modules);
|
|
|
|
+ this.$set(this, `menu`, r);
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
selectMenu(path, modules) {
|
|
selectMenu(path, modules) {
|
|
if (this.project_modules === modules) this.$router.push({ path: path });
|
|
if (this.project_modules === modules) this.$router.push({ path: path });
|
|
},
|
|
},
|
|
|
|
+ filterMenu(menus, umod) {
|
|
|
|
+ let nm = menus.map(menu => {
|
|
|
|
+ //mod 不存在:检查下面每一子项是否有限制
|
|
|
|
+ //mod 存在:检查是否符合要求,符合,检查子项;不符合,略过
|
|
|
|
+ let mod = _.get(menu, 'module');
|
|
|
|
+ if ((mod && mod.includes(umod)) || !mod) {
|
|
|
|
+ let children = _.get(menu, 'children');
|
|
|
|
+ if (children) {
|
|
|
|
+ menu.children = this.filterMenu(children, umod);
|
|
|
|
+ }
|
|
|
|
+ return menu;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return _.compact(nm);
|
|
|
|
+ },
|
|
},
|
|
},
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
@@ -110,24 +117,5 @@ export default {
|
|
width: 100% !important;
|
|
width: 100% !important;
|
|
border: none;
|
|
border: none;
|
|
}
|
|
}
|
|
- .el-submenu .el-menu-item {
|
|
|
|
- min-width: 16rem !important;
|
|
|
|
- padding-left: 3rem !important;
|
|
|
|
- background-color: #000c17 !important;
|
|
|
|
- &:hover {
|
|
|
|
- color: #fff !important;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- .el-menu-item,
|
|
|
|
- .el-submenu .el-menu-item {
|
|
|
|
- &.is-active {
|
|
|
|
- background-color: #188fff !important;
|
|
|
|
- color: #fff !important;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- .el-submenu__title i {
|
|
|
|
- font-size: 1rem;
|
|
|
|
- color: rgba(255, 255, 255, 0.65);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|