index.vue 1.69 KB
<!--
 * @Description: I
 * @Author: huyue
 * @Date: 2024-07-24 20:28:10
 * @LastEditors: huyue
 * @LastEditTime: 2024-10-18 16:02:45
-->

<script lang="ts" setup>
import { ref, onBeforeMount } from 'vue'
import staticRoutes from '@/router/routes'
import { useRouter, useRoute } from 'vue-router';
// import icon from './icon';
const router = useRouter();
const route = useRoute();
let defaultSelectedKeys = ref(['']);
const routerList = staticRoutes.find(item => item.path === '/layout')?.children;
const menuList = ref(routerList!.filter(item => item.isMenu));
onBeforeMount (() => {
  const _parentPath = routerList!.find(item => item.path === route.path)?.parentPath
  defaultSelectedKeys.value = _parentPath === undefined ? ['/investorRelated'] : [_parentPath]
})
</script>
<template>
  <div class="menu-box">
    <a-menu
    class="menu"
    :style="{ width: '200px', height: '100%' }"
    :default-open-keys="defaultSelectedKeys"
    :default-selected-keys="defaultSelectedKeys"
  >
  <div v-for="(item, index) in menuList" :key="'menu-item-' + index">
    <a-menu-item :key="item.path" @click="router.push(item.path)">
     <!-- <icon :name="item.icon" /> -->
     <template v-if="item.path === '/investorRelated'">
       <icon-user />
     </template>
     <template v-if="item.path === '/news'">
       <icon-public />
     </template>
      <span>{{ item.name }}</span>
    </a-menu-item>
  </div>
  </a-menu>
  </div>
</template>
<style lang="scss" scoped>
.menu-box {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding-top: 24px;
  .arco-menu-light .arco-menu-item.arco-menu-selected {
    background-color: rgba(25, 95, 254, .08);
  }
}
</style>