<template>
  <el-scrollbar wrap-class="scrollbar-wrapper">
    <el-menu
      :show-timeout="200"
      :default-active="$route.path"
      :collapse="isCollapse"
      mode="vertical"
      background-color="#2f3856"
      text-color="#bfcbd9"
      active-text-color="#1bb1a5"
    >
      <sidebar-item v-for="route in permission_routers" :key="route.path" :item="route" :base-path="route.path"/>
    </el-menu>
  </el-scrollbar>
</template>

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

export default {
  components: { SidebarItem },
  computed: {
    permission_routers() {
      let permission_routers = this.$store.getters.permission_routers
      const currentSystem = this.$store.getters.currentSystem
      permission_routers = permission_routers.filter(item => {
        if (item.meta && item.meta.sys && item.meta.sys === currentSystem.url) {
          return true
        }
      })
      return permission_routers
    },
    ...mapGetters([
      // 'permission_routers',
      'sidebar'
    ]),
    isCollapse() {
      return !this.sidebar.opened
    }
  }
}
</script>
