2024-05-19 21:20:42 +08:00
|
|
|
<script lang="ts" setup>
|
2024-07-23 00:03:59 +08:00
|
|
|
import type { MenuRecordRaw } from '@vben/types';
|
2024-05-19 21:20:42 +08:00
|
|
|
|
2024-05-21 21:45:48 +08:00
|
|
|
import { useRoute } from 'vue-router';
|
|
|
|
|
2024-06-08 19:49:06 +08:00
|
|
|
import { Menu, MenuProps } from '@vben-core/menu-ui';
|
|
|
|
|
2024-05-21 21:45:48 +08:00
|
|
|
import { useNavigation } from './use-navigation';
|
2024-05-19 21:20:42 +08:00
|
|
|
|
|
|
|
interface Props extends MenuProps {
|
2024-07-14 13:48:47 +08:00
|
|
|
collapse?: boolean;
|
2024-05-19 21:20:42 +08:00
|
|
|
menus: MenuRecordRaw[];
|
|
|
|
}
|
|
|
|
|
2024-05-22 22:56:26 +08:00
|
|
|
withDefaults(defineProps<Props>(), {
|
|
|
|
accordion: true,
|
|
|
|
menus: () => [],
|
|
|
|
});
|
2024-05-19 21:20:42 +08:00
|
|
|
|
|
|
|
const route = useRoute();
|
2024-05-21 21:45:48 +08:00
|
|
|
const { navigation } = useNavigation();
|
2024-05-19 21:20:42 +08:00
|
|
|
|
2024-05-21 21:45:48 +08:00
|
|
|
async function handleSelect(key: string) {
|
|
|
|
await navigation(key);
|
2024-05-19 21:20:42 +08:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<Menu
|
2024-05-22 22:56:26 +08:00
|
|
|
:accordion="accordion"
|
2024-05-19 21:20:42 +08:00
|
|
|
:collapse="collapse"
|
|
|
|
:default-active="route.path"
|
|
|
|
:menus="menus"
|
2024-06-09 13:31:43 +08:00
|
|
|
:rounded="rounded"
|
2024-05-19 21:20:42 +08:00
|
|
|
:theme="theme"
|
|
|
|
mode="vertical"
|
|
|
|
@select="handleSelect"
|
|
|
|
/>
|
|
|
|
</template>
|