<template>
|
<div :class="{ 'has-logo': showLogo }">
|
<logo
|
v-if="showLogo"
|
:collapse="isCollapse"
|
/>
|
<!-- <div class="logo" style="display:flex;background: #0f4567;">
|
<img
|
style="width: 20px; height: 30px;margin: 8px 0 11px 18px"
|
:src="logo"
|
>
|
<p v-show="this.$store.state.logoDisplay" style="font-size: 15px;color: #eee;padding-left:5px">七星瓢虫环境科技</p>
|
</div> -->
|
<el-scrollbar wrap-class="scrollbar-wrapper">
|
<el-menu
|
:default-active="activeMenu"
|
:collapse="isCollapse"
|
:background-color="variables.menuBg"
|
:text-color="variables.menuText"
|
:unique-opened="false"
|
:active-text-color="variables.menuActiveText"
|
:collapse-transition="false"
|
mode="vertical"
|
>
|
<sidebar-item
|
v-for="route in routes"
|
:key="route.path"
|
:item="route"
|
:base-path="route.path"
|
/>
|
</el-menu>
|
</el-scrollbar>
|
</div>
|
</template>
|
|
<script>
|
import { mapGetters } from 'vuex'
|
import Logo from './Logo'
|
import SidebarItem from './SidebarItem'
|
import variables from '@/styles/variables.scss'
|
|
export default {
|
components: { SidebarItem, Logo },
|
data () {
|
return {
|
logo: require('@/assets/images/LOGO.png'),
|
logoDisplay: this.$store.state.logoDisplay
|
}
|
},
|
computed: {
|
...mapGetters([
|
'sidebar'
|
]),
|
sidebar () {
|
console.log('左边sidebar', this.$store.state.app.sidebar)
|
return this.$store.state.app.sidebar
|
},
|
routes () {
|
console.log('左边routes', this.$router.options.routes)
|
return this.$router.options.routes
|
},
|
activeMenu () {
|
const route = this.$route
|
const { meta, path } = route
|
// if set path, the sidebar will highlight the path you set
|
if (meta.activeMenu) {
|
return meta.activeMenu
|
}
|
return path
|
},
|
showLogo () {
|
return !this.$store.state.settings.sidebarLogo
|
},
|
variables () {
|
return variables
|
},
|
isCollapse () {
|
return !this.sidebar.opened
|
}
|
}
|
}
|
</script>
|