<!--
 * @Description: 
 * @Autor: linqian
 * @Date: 2021-04-06 08:44:43
-->
<template>
    <div class="l-sidebar__container">
        <div class="l-sidebar__header">
            <i class="el-icon-s-fold" :class="[isCollapse ? 'is-active' : '']" @click="toggleSideBar"></i>
        </div>
        <div class="l-sidebar__content">
            <el-scrollbar wrap-class="l-sidebar__scrollbar">
                <div class="u-menu">
                    <el-menu
                        class="u-menu__container"
                        :show-timeout="200"
                        :default-active="$route.path"
                        :collapse="isCollapse"
                        :collapse-transition="false"
                        mode="vertical"
                    >
                        <sidebar-item
                            class="u-menu__list"
                            v-for="route in permission_routers"
                            :key="route.path"
                            :item="route"
                            :base-path="route.path"
                        />
                    </el-menu>
                </div>
            </el-scrollbar>
        </div>
        <div class="l-sidebar__container-toggle" @click=handleToggleMenu>
            <i :class="{ 'el-icon-s-unfold': fold === 0, 'el-icon-s-fold': fold === 1 }"></i>
        </div>
    </div>
</template>

<script>
import { mapGetters } from "vuex";
import SidebarItem from "./sidebar-item";

export default {
    components: { SidebarItem },
    data(){
      return{
          fold: 1,
      }
    },
    computed: {
        ...mapGetters(["permission_routers", "sidebar"]),
        isCollapse() {
            return !this.sidebar.opened;
        }
    },
    methods: {
        toggleSideBar() {
            this.$store.dispatch("toggleSideBar");
        },
        /**
         *
         * 切换菜单
         *
         * */
        handleToggleMenu(){
            $(".l-sidebar__header i").click();
            if(this.fold  === 0){
                this.fold = 1
            }else{
                this.fold = 0
            }
        }
    }
};
</script>
<style lang="scss" scoped>
// /deep/ .l-sidebar__scrollbar {
//     margin-bottom: -17px !important;
//     margin-right: -17px !important;
// }
</style>
