feat: prototype big picture mode

This commit is contained in:
DecDuck
2025-09-23 18:05:35 +10:00
parent 864640d6ae
commit dbf9c8e8e5
62 changed files with 10306 additions and 214 deletions

View File

@ -0,0 +1,32 @@
import type { RouteLocationNormalized } from "vue-router";
import type { NavigationItem } from "~/types";
export const useCurrentNavigationIndex = (
navigation: Array<NavigationItem>
) => {
const router = useRouter();
const route = useRoute();
const currentNavigation = ref(-1);
function calculateCurrentNavIndex(to: RouteLocationNormalized) {
const validOptions = navigation
.map((e, i) => ({ ...e, index: i }))
.filter((e) => to.fullPath.startsWith(e.prefix));
const bestOption = validOptions
.sort((a, b) => b.route.length - a.route.length)
.at(0);
return bestOption?.index ?? -1;
}
currentNavigation.value = calculateCurrentNavIndex(route);
router.afterEach((to) => {
currentNavigation.value = calculateCurrentNavIndex(to);
});
return {currentNavigation, recalculateNavigation: () => {
currentNavigation.value = calculateCurrentNavIndex(route);
}};
};