mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
feat: add folder navigation and improve menu item handling (#1498)
This commit is contained in:
@@ -350,6 +350,41 @@
|
|||||||
return items;
|
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 activeMenuIndex = computed(() => {
|
||||||
const currentRouteName = router.currentRoute.value?.name;
|
const currentRouteName = router.currentRoute.value?.name;
|
||||||
if (!currentRouteName) {
|
if (!currentRouteName) {
|
||||||
@@ -691,7 +726,11 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleMenuItemClick = (item) => {
|
const handleMenuItemClick = (item) => {
|
||||||
if (!item || item.entries?.length) {
|
if (!item) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (item.entries?.length) {
|
||||||
|
handleFolderCycleNavigation(item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handleRouteChange(item.routeName, item.index);
|
handleRouteChange(item.routeName, item.index);
|
||||||
|
|||||||
@@ -24,15 +24,6 @@ export const useUiStore = defineStore('Ui', () => {
|
|||||||
const notifiedMenus = ref([]);
|
const notifiedMenus = ref([]);
|
||||||
const shiftHeld = ref(false);
|
const shiftHeld = ref(false);
|
||||||
const trayIconNotify = 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(
|
watch(
|
||||||
() => watchState.isLoggedIn,
|
() => watchState.isLoggedIn,
|
||||||
(isLoggedIn) => {
|
(isLoggedIn) => {
|
||||||
@@ -63,11 +54,6 @@ export const useUiStore = defineStore('Ui', () => {
|
|||||||
if (name === 'notification') {
|
if (name === 'notification') {
|
||||||
notificationStore.unseenNotifications = [];
|
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 {
|
return {
|
||||||
notifiedMenus,
|
notifiedMenus,
|
||||||
shiftHeld,
|
shiftHeld,
|
||||||
lastVisitedSocialRoute,
|
|
||||||
lastVisitedFavoritesRoute,
|
|
||||||
|
|
||||||
notifyMenu,
|
notifyMenu,
|
||||||
removeNotify
|
removeNotify
|
||||||
|
|||||||
Reference in New Issue
Block a user