2024-04-13 22:09:14 +08:00
|
|
|
|
<template>
|
2024-04-20 16:54:12 +08:00
|
|
|
|
<a-menu
|
|
|
|
|
|
breakpoint="xl"
|
|
|
|
|
|
:collapsed="collapsed"
|
2024-05-04 23:36:38 +08:00
|
|
|
|
:auto-scroll-into-view="true"
|
2024-04-20 16:54:12 +08:00
|
|
|
|
:auto-open-selected="true"
|
2024-05-04 23:36:38 +08:00
|
|
|
|
:accordion="isAccordion"
|
2024-04-20 16:54:12 +08:00
|
|
|
|
:selected-keys="[currentRoute.name]"
|
|
|
|
|
|
@menu-item-click="onMenuItem"
|
|
|
|
|
|
>
|
2024-04-13 22:09:14 +08:00
|
|
|
|
<MenuItem :route-tree="routeTree" />
|
|
|
|
|
|
</a-menu>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import MenuItem from "@/layout/components/Menu/menu-item.vue";
|
|
|
|
|
|
import { storeToRefs } from "pinia";
|
2024-04-28 13:38:12 +08:00
|
|
|
|
import { useThemeConfig } from "@/store/modules/theme-config";
|
|
|
|
|
|
import { useRoutesListStore } from "@/store/modules/route-list";
|
2024-04-18 00:24:07 +08:00
|
|
|
|
import { useRouter } from "vue-router";
|
2024-04-20 16:54:12 +08:00
|
|
|
|
import { useRoutingMethod } from "@/hooks/useRoutingMethod";
|
2024-04-18 00:24:07 +08:00
|
|
|
|
const router = useRouter();
|
2024-04-13 22:09:14 +08:00
|
|
|
|
const routerStore = useRoutesListStore();
|
2024-04-20 16:54:12 +08:00
|
|
|
|
const { routeTree, currentRoute } = storeToRefs(routerStore);
|
2024-04-13 22:09:14 +08:00
|
|
|
|
const themeStore = useThemeConfig();
|
2024-05-04 23:36:38 +08:00
|
|
|
|
const { collapsed, isAccordion } = storeToRefs(themeStore);
|
2024-04-13 22:09:14 +08:00
|
|
|
|
|
2024-04-21 00:26:49 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @description 菜单点击事件
|
|
|
|
|
|
* @param {String} key
|
|
|
|
|
|
*/
|
2024-04-18 00:24:07 +08:00
|
|
|
|
const onMenuItem = (key: string) => {
|
2024-04-20 16:54:12 +08:00
|
|
|
|
const { findLinearArray } = useRoutingMethod();
|
|
|
|
|
|
const find = findLinearArray(key);
|
2024-04-21 00:26:49 +08:00
|
|
|
|
// 路由存在则存入并跳转,不存在则跳404
|
2024-04-18 00:24:07 +08:00
|
|
|
|
if (find) {
|
|
|
|
|
|
router.push(find.path);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
router.push("/404");
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2024-04-13 22:09:14 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
2024-05-01 23:56:53 +08:00
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
// .arco-menu-light {
|
|
|
|
|
|
// background: unset;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// .arco-menu-light .arco-menu-item {
|
|
|
|
|
|
// background: unset;
|
|
|
|
|
|
// }
|
|
|
|
|
|
</style>
|