mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-14 12:23:52 +02:00
feat: add folder navigation and improve menu item handling (#1498)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user