<template>
  <el-menu
    active-text-color="#ffd04b"
    background-color="#545c64"
    :default-active="active"
    text-color="#fff"
    router
  >
    <el-menu-item v-for="item in menuList" :key="item.index" :index="item.index" :route="item.path">
      <span>{{ item.name }}</span>
    </el-menu-item>
  </el-menu>
</template>

<script setup lang="ts">
import { menuList } from '../uilts/menuList'

const route = useRoute()

const active: any = ref(1)

watch(
  () => route.path,
  (newPath: string) => {
    active.value = menuList.find((item: any) => newPath === item.path)?.index
  },
  { immediate: true }
)
</script>

<style scoped>
.el-menu {
  height: 100%;
}
</style>
