index.vue
1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!--
* @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>