<script setup>
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import sidebarItem from './sidebarItem.vue'
import { storeToRefs } from 'pinia'
import store from '@/store'
const props = defineProps({
  isCollapse: {
    type: Boolean,
    default: false
  },
  sidebarMenu: {
    type: Array,
    default: () => []
  }
})
const userInfo = storeToRefs(store.userStore).userInfo
const active = computed(() => {
  const route = useRoute()
  const { meta, name } = route
  if (meta.activeMenu) {
    return meta.activeMenu
  }
  return name
})
</script>
<template>
  <el-menu
    :default-active="active"
    :collapse="props.isCollapse"
    class="el-menu-vertical-demo"
    unique-opened
  >
    <sidebar-item
      v-for="item in userInfo.regionCode!=='331123'?props.sidebarMenu.filter(i=>i.name!=='applicationRegist'):props.sidebarMenu"
      :key="item.name"
      :index="item.name"
      :title="item.meta.title"
      :item="item"
      :active="active"
    />
  </el-menu>
</template>
