|
@@ -1,87 +1,85 @@
|
|
<template>
|
|
<template>
|
|
- <div class="sidebar">
|
|
|
|
- <el-menu
|
|
|
|
- class="sidebar-el-menu"
|
|
|
|
- :default-active="onRoutes"
|
|
|
|
- :collapse="collapse"
|
|
|
|
- background-color="#324157"
|
|
|
|
- text-color="#bfcbd9"
|
|
|
|
- active-text-color="#20a0ff"
|
|
|
|
- unique-opened
|
|
|
|
- router
|
|
|
|
- >
|
|
|
|
- <template v-for="item in items">
|
|
|
|
- <template v-if="item.subs">
|
|
|
|
- <el-submenu class="second" :index="item.index" :key="item.index">
|
|
|
|
- <template slot="title">
|
|
|
|
- <i :class="item.icon"></i>
|
|
|
|
- <span slot="title">{{ item.title }}</span>
|
|
|
|
|
|
+ <div id="Sidebar">
|
|
|
|
+ <el-row class="sidebar">
|
|
|
|
+ <el-col :span="24" class="main">
|
|
|
|
+ <el-col :span="24" class="one">
|
|
|
|
+ <el-menu
|
|
|
|
+ class="sidebar-el-menu"
|
|
|
|
+ :default-active="onRoutes"
|
|
|
|
+ :collapse="collapse"
|
|
|
|
+ background-color="#324157"
|
|
|
|
+ text-color="#bfcbd9"
|
|
|
|
+ active-text-color="#20a0ff"
|
|
|
|
+ unique-opened
|
|
|
|
+ router
|
|
|
|
+ >
|
|
|
|
+ <template v-for="item in items">
|
|
|
|
+ <template v-if="item.subs">
|
|
|
|
+ <el-submenu :index="item.index" :key="item.index">
|
|
|
|
+ <template slot="title">
|
|
|
|
+ <i :class="['iconfont', item.icon]"></i>
|
|
|
|
+ <span slot="title">{{ item.title }}</span>
|
|
|
|
+ </template>
|
|
|
|
+ <template v-for="subItem in item.subs">
|
|
|
|
+ <el-submenu v-if="subItem.subs" :index="subItem.index" :key="subItem.index">
|
|
|
|
+ <template slot="title">{{ subItem.title }}</template>
|
|
|
|
+ <el-menu-item v-for="(threeItem, i) in subItem.subs" :key="i" :index="threeItem.index">{{ threeItem.title }}</el-menu-item>
|
|
|
|
+ </el-submenu>
|
|
|
|
+ <el-menu-item v-else :index="subItem.index" :key="subItem.index">{{ subItem.title }}</el-menu-item>
|
|
|
|
+ </template>
|
|
|
|
+ </el-submenu>
|
|
|
|
+ </template>
|
|
|
|
+ <template v-else>
|
|
|
|
+ <el-menu-item class="first" :index="item.index" :key="item.index">
|
|
|
|
+ <i :class="['iconfont', item.icon]"></i>
|
|
|
|
+ <span slot="title">{{ item.title }}</span>
|
|
|
|
+ </el-menu-item>
|
|
|
|
+ </template>
|
|
</template>
|
|
</template>
|
|
- <template v-for="subItem in item.subs">
|
|
|
|
- <el-submenu v-if="subItem.subs" :index="subItem.index" :key="subItem.index">
|
|
|
|
- <template slot="title">{{ subItem.title }}</template>
|
|
|
|
- <el-menu-item v-for="(threeItem, i) in subItem.subs" :key="i" :index="threeItem.index">{{ threeItem.title }}</el-menu-item>
|
|
|
|
- </el-submenu>
|
|
|
|
- <el-menu-item v-else :index="subItem.index" :key="subItem.index">{{ subItem.title }}</el-menu-item>
|
|
|
|
- </template>
|
|
|
|
- </el-submenu>
|
|
|
|
- </template>
|
|
|
|
- <template v-else>
|
|
|
|
- <el-menu-item class="first" :index="item.index" :key="item.index">
|
|
|
|
- <i :class="item.icon"></i>
|
|
|
|
- <span slot="title">{{ item.title }}</span>
|
|
|
|
- </el-menu-item>
|
|
|
|
- </template>
|
|
|
|
- </template>
|
|
|
|
- </el-menu>
|
|
|
|
|
|
+ </el-menu>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import _ from 'lodash';
|
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
+import _ from 'lodash';
|
|
import bus from './bus';
|
|
import bus from './bus';
|
|
export default {
|
|
export default {
|
|
- data() {
|
|
|
|
|
|
+ name: 'Sidebar',
|
|
|
|
+ props: {},
|
|
|
|
+ components: {},
|
|
|
|
+ data: function() {
|
|
return {
|
|
return {
|
|
collapse: false,
|
|
collapse: false,
|
|
- items: [
|
|
|
|
- {
|
|
|
|
- icon: 'el-icon-s-home',
|
|
|
|
- index: '/adminCenter/homeIndex',
|
|
|
|
- title: '系统首页',
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
|
|
+ items: [{ icon: 'icon-shouye', index: '/adminCenter/homeIndex', title: '系统首页' }],
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- computed: {
|
|
|
|
- ...mapState(['user']),
|
|
|
|
- onRoutes() {
|
|
|
|
- return this.$route.path.replace('/', '');
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
created() {
|
|
created() {
|
|
- // 通过 Event Bus 进行组件间通信,来折叠侧边栏
|
|
|
|
- bus.$on('collapse', (msg) => {
|
|
|
|
|
|
+ bus.$on('collapse', msg => {
|
|
this.collapse = msg;
|
|
this.collapse = msg;
|
|
bus.$emit('collapse-content', msg);
|
|
bus.$emit('collapse-content', msg);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- // 分配用户彩带权限
|
|
|
|
- async getMenu() {
|
|
|
|
|
|
+ getMenu() {
|
|
let list = _.cloneDeep(this.items);
|
|
let list = _.cloneDeep(this.items);
|
|
- let data = [
|
|
|
|
- {
|
|
|
|
- icon: 'el-icon-s-home',
|
|
|
|
- index: '/adminCenter/test/index',
|
|
|
|
- title: '测试页面',
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
|
|
+ let data = [{ icon: 'icon-ceshi', index: '/adminCenter/test/index', title: '测试页面' }];
|
|
list.push(...data);
|
|
list.push(...data);
|
|
this.$set(this, `items`, _.uniqBy(list, 'index'));
|
|
this.$set(this, `items`, _.uniqBy(list, 'index'));
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapState(['user']),
|
|
|
|
+ onRoutes() {
|
|
|
|
+ return this.$route.path.replace('/', '');
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ metaInfo() {
|
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
|
+ },
|
|
watch: {
|
|
watch: {
|
|
user: {
|
|
user: {
|
|
deep: true,
|
|
deep: true,
|
|
@@ -102,6 +100,7 @@ export default {
|
|
top: 60px;
|
|
top: 60px;
|
|
bottom: 0;
|
|
bottom: 0;
|
|
overflow-y: scroll;
|
|
overflow-y: scroll;
|
|
|
|
+ background-color: rgb(50, 65, 87);
|
|
}
|
|
}
|
|
.sidebar::-webkit-scrollbar {
|
|
.sidebar::-webkit-scrollbar {
|
|
width: 0;
|
|
width: 0;
|
|
@@ -112,10 +111,12 @@ export default {
|
|
.sidebar > ul {
|
|
.sidebar > ul {
|
|
height: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
-// /deep/.first {
|
|
|
|
-// padding-left: 0 !important;
|
|
|
|
-// }
|
|
|
|
-// /deep/.second .el-submenu__title {
|
|
|
|
-// padding-left: 0 !important;
|
|
|
|
-// }
|
|
|
|
|
|
+.main {
|
|
|
|
+ .one {
|
|
|
|
+ .iconfont {
|
|
|
|
+ font-size: 18px;
|
|
|
|
+ margin: 0 5px 0 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
</style>
|
|
</style>
|