<template>
  <div class="sidebar">
    <el-menu
      class="sidebar-el-menu"
      :default-active="onRoutes"
      :collapse="collapse"
      background-color="#324157"
      text-color="#bfcbd9"
      active-text-color="#20a0ff"
      unique-opened
      router
    >
    
      <template v-for="item in router.options.routes[1].children">
        <template v-if="item.children">
          <el-submenu :index="item.path" :key="item.name"  v-if="item.isshow?.includes(identity) || !item.isshow">
            <template #title>
              <i :class="item.icon" style="margin-right:10px"></i>
              <span>{{ item.meta.title }}</span>
            </template>

            <template v-for="subItem in item.children" :key="subItem.name">
              <el-menu-item :index="subItem.path">
                {{ subItem.meta.title }}
              </el-menu-item>
            </template>
          </el-submenu>
        </template>

        <template v-else >
          <el-menu-item :index="item.path" :key="item.path"  v-if="(item.isshow?.includes(identity) || !item.isshow) &&item.path!=='/check'">
            <i :class="item.icon" style="margin-right:10px"></i>
            <template #title>{{ item.meta.title }}</template>
          </el-menu-item>
        </template>
        
      </template>
    </el-menu>
  </div>
</template>

<script setup>
import { computed, warn } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useStore } from "vuex";
const identity = sessionStorage.getItem("identity")

const route = useRoute();
const store = useStore();
const router = useRouter();
let onRoutes = computed(() => route.path.replace("/", ""));
let collapse = computed(() => store.state.collapse);
</script>

<style scoped>
.sidebar {
  display: block;
  position: absolute;
  left: 0;
  top: 70px;
  bottom: 0;
  overflow-y: scroll;
}
.sidebar::-webkit-scrollbar {
  width: 0;
}
.sidebar-el-menu:not(.el-menu--collapse) {
  width: 250px;
}
.sidebar > ul {
  height: 100%;
}
</style>
