<template>
  <div>
    <el-scrollbar wrap-class="scrollbar-wrapper">
      <div v-show="isShow" class="img-wrapper"><img :src="require('@/assets/img/gaojingLogo.png')"></div>
      <el-menu
        :show-timeout="200"
        :default-active="$route.path"
        :collapse="isCollapse"
        mode="vertical"
        background-color="#304156"
        text-color="#cccccc"
        active-text-color="#409EFF"
        style="height:calc(100% - 124px)"
      >
        <sidebar-item v-for="route in permission_routers" :key="route.name" :item="route" :base-path="route.path"/>
      </el-menu>
    </el-scrollbar>
  </div>

</template>

<script>
import { mapGetters } from 'vuex'
import SidebarItem from './SidebarItem'

export default {
  components: { SidebarItem },
  data() {
    return {
      isShow: ''
    }
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'permission_routers'
    ]),
    routes() {
      return this.$router.options.routes
    },
    isCollapse() {
      this.showLogo()
      return !this.sidebar.opened
    }
  },
  methods: {
    showLogo() {
      if (this.sidebar.opened === true) {
        this.isShow = true
      } else {
        this.isShow = false
      }
    }
  }
}
</script>
<style lang="scss" scoped>
  .img-wrapper{
    img{
      width: 84px;
      margin: 20px 60px 20px 60px;
    }
  }
</style>
