From ccc0160de1b263dea0c5c4029097319e71d581ae Mon Sep 17 00:00:00 2001 From: pa Date: Wed, 19 Nov 2025 23:05:16 +0900 Subject: [PATCH] feat: add folder navigation and improve menu item handling (#1498) --- src/components/NavMenu.vue | 41 +++++++++++++++++++++++++++++++++++++- src/stores/ui.js | 16 --------------- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/components/NavMenu.vue b/src/components/NavMenu.vue index 246325e3..715a8e4d 100644 --- a/src/components/NavMenu.vue +++ b/src/components/NavMenu.vue @@ -350,6 +350,41 @@ return items; }); + const folderCyclePointers = new Map(); + + const navigateToFolderEntry = (folderIndex, entry) => { + if (!entry) { + return; + } + if (entry.routeName) { + handleRouteChange(entry.routeName, folderIndex); + return; + } + if (entry.path) { + router.push(entry.path); + if (folderIndex) { + navMenuRef.value?.updateActiveIndex(folderIndex); + } + } + }; + + const handleFolderCycleNavigation = (item) => { + if (!item?.entries?.length) { + return []; + } + const entries = item.entries.filter((entry) => Boolean(entry?.routeName || entry?.path)); + if (!entries.length) { + return; + } + let pointer = folderCyclePointers.get(item.index) ?? 0; + if (pointer >= entries.length || pointer < 0) { + pointer = 0; + } + const entry = entries[pointer]; + folderCyclePointers.set(item.index, (pointer + 1) % entries.length); + navigateToFolderEntry(item.index, entry); + }; + const activeMenuIndex = computed(() => { const currentRouteName = router.currentRoute.value?.name; if (!currentRouteName) { @@ -691,7 +726,11 @@ }; const handleMenuItemClick = (item) => { - if (!item || item.entries?.length) { + if (!item) { + return; + } + if (item.entries?.length) { + handleFolderCycleNavigation(item); return; } handleRouteChange(item.routeName, item.index); diff --git a/src/stores/ui.js b/src/stores/ui.js index 5b8ded08..52dfd3ee 100644 --- a/src/stores/ui.js +++ b/src/stores/ui.js @@ -24,15 +24,6 @@ export const useUiStore = defineStore('Ui', () => { const notifiedMenus = ref([]); const shiftHeld = ref(false); const trayIconNotify = ref(false); - const socialRouteNames = ['friend-log', 'friend-list', 'moderation']; - const favoriteRouteNames = [ - 'favorite-friends', - 'favorite-worlds', - 'favorite-avatars' - ]; - const lastVisitedSocialRoute = ref(socialRouteNames[0]); - const lastVisitedFavoritesRoute = ref(favoriteRouteNames[0]); - watch( () => watchState.isLoggedIn, (isLoggedIn) => { @@ -63,11 +54,6 @@ export const useUiStore = defineStore('Ui', () => { if (name === 'notification') { notificationStore.unseenNotifications = []; } - if (socialRouteNames.includes(name)) { - lastVisitedSocialRoute.value = name; - } else if (favoriteRouteNames.includes(name)) { - lastVisitedFavoritesRoute.value = name; - } } } ); @@ -96,8 +82,6 @@ export const useUiStore = defineStore('Ui', () => { return { notifiedMenus, shiftHeld, - lastVisitedSocialRoute, - lastVisitedFavoritesRoute, notifyMenu, removeNotify