<template>
  <div :class="{ 'has-logo': showLogo }">
    <!-- <logo :collapse="isCollapse" @toIndex="toIndex" /> -->
    <el-scrollbar wrap-class="scrollbar-wrapper">
      <el-menu
        :default-active="currPath"
        :collapse="isCollapse"
        :background-color="variables.menuBg"
        :text-color="variables.menuText"
        :unique-opened="false"
        :active-text-color="variables.menuActiveText"
      >
        <sidebar-item
          v-if="permissionRoutes"
          @retParentObj="getParentObj"
          v-for="route in permissionRoutes"
          :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 },
  computed: {
    ...mapGetters(["permissionRoutes", "sidebar"]),
    activeMenu() {
      const route = this.$route;
      const { meta, path } = route;
      if (meta.activeMenu) {
        return meta.activeMenu;
      }
      return path;
    },
    showLogo() {
      return this.$store.state.settings.sidebarLogo;
    },
    variables() {
      return variables;
    },
    isCollapse() {
      return false;
    }
  },
  data() {
    return {
      currPath: this.$route.path
    };
  },
  methods: {
    toIndex() {
      this.$emit("retParentMenu", null);
      this.$router.push({ path: "/index" });
    },
    getParentObj(obj) {
      this.$emit("retParentMenu", obj);
      if (obj != null) {
        this.currPath = obj.path;
      } else {
        const route = this.$route;
        const { meta, path } = route;
        return (this.currPath = path);
      }
    }
  }
};
</script>
<style type="text/css" scoped=""></style>
