<template>
  <el-aside class="siderbar_container" :width="isCollapse ? '72px' : '150px'">
    <div @click="toggleCollapse">
      <img v-if="isCollapse" src="@/assets/icon/open.svg" alt="">
      <img v-else src="@/assets/icon/close.svg" alt="">
    </div>
    <el-menu :collapse="isCollapse" router @handleOpen="handleOpen" @handleClose="handleClose">
      <el-menu-item v-for="item in menuItems" :key="item.route" :index="item.route">
        <template #title>
          <!-- <img :src="`@/assets/icon/${item.icon}.svg`" alt=""> -->
          <img src="`@/assets/icon/manage_normal.svg`" alt="">
          <span>{{ item.label }}</span>
        </template>
      </el-menu-item>
    </el-menu>
  </el-aside>
</template>

<script> 
import { ref } from 'vue';
export default {
  name: 'SiderBar',
  components: {
  },
  setup() {
    const isCollapse = ref(false)
    const menuItems = ref([
      {
        label: '学校管理',
        icon: 'school_normal',
        icon_light: 'school_light',
        icon_hover: 'school_hover',
        route: '/main/school',
      },
      {
        label: '运维管理',
        icon: 'manage_normal',
        icon_light: 'school_light',
        icon_hover: 'school_hover',
        route: '/main/manager',
      },
      {
        label: '联考管理',
        icon: 'join_exam_normal',
        icon_light: 'join_exam_light',
        icon_hover: 'join_exam_hover',
        route: '/main/examination',
      }
    ])
    const handleOpen = (key, keyPath) => {
      console.log(key, keyPath)
    }
    const handleClose = (key, keyPath) => {
      console.log(key, keyPath)
    }
    const toggleCollapse = () => {
      isCollapse.value = !isCollapse.value
    }
    return {
      isCollapse,
      menuItems,
      handleOpen,
      handleClose,
      toggleCollapse,
      
    }
  }
}
</script>

<style scoped>
.siderbar_container {
  background: #fff;
  padding: 16px;
}
.el-menu {
  width: 100%;
  border: none;
}
.el-menu-item {
  padding: 0;
}
</style>