diff --git a/src/components/sidebar/AppSidebar.vue b/src/components/sidebar/AppSidebar.vue
index ab3d415a..dbad4ec6 100644
--- a/src/components/sidebar/AppSidebar.vue
+++ b/src/components/sidebar/AppSidebar.vue
@@ -1,8 +1,9 @@
@@ -397,6 +412,8 @@ const defaultExpandedKeys = computed(() => {
{
import { Icon } from "@iconify/vue";
-import type { MenuOption } from "naive-ui";
+import type { MenuInst, MenuOption } from "naive-ui";
import { NLayoutSider, NMenu, NSpace } from "naive-ui";
import { computed, h, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
@@ -197,6 +197,20 @@ const showSidebar = computed(() => {
return false;
});
+
+const selectedKeyRef = ref("1");
+const menuInstRef = ref(null);
+
+const selectAndExpand = (key: string) => {
+ selectedKeyRef.value = key;
+ menuInstRef.value?.showOption(key);
+};
+
+router.beforeEach((to, from) => {
+ if (typeof to.name !== "string") return;
+ const name: string = to.meta && to.meta.menuItem ? (to.meta.menuItem as string) : to.name;
+ selectAndExpand(name);
+});
@@ -213,6 +227,8 @@ const showSidebar = computed(() => {
>