<template>
  <div>
    <el-scrollbar wrap-class="scrollbar-wrapper">
      <div v-show="isShow" class="img-wrapper">
        <div style="background-color: #fff; height: 49px; width:100%">
          <img :src="require('@/assets/img/logo.png')">
        </div>
      </div>
      <div v-show="!isShow" class="img-wrapper-small">
        <div style="background-color: #fff; height: 49px; width:100%">
          <img :src="require('@/assets/img/DFlogo.png')" width="60">
        </div>
      </div>
      <el-menu
        :collapse="isCollapse"
        :default-active="$route.path"
        :show-timeout="200"
        mode="vertical"
        style="height:calc(100% - 49px)"
      >
        <sidebar-item v-for="route in permission_routers" :key="route.name" :base-path="route.path" :item="route"/>
      </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() {
      this.isShow = this.sidebar.opened === true
    }
  }
}
</script>
<style lang="scss" scoped>
.img-wrapper {
  img {
    width: 200px;
  }
}

.img-wrapper-small {
  img {
    margin: 7px 9px;
  }
}
.img-wrapper img {
    width: auto;
    height: 100%;
}
.img-wrapper-small {
  img {
    margin: 0px 9px;
    height: 100%;
    width: auto;
  }
}

</style>
