feat(settings): more specific notification handling, and put menu in query to allow user to go back in history to go back in menus
This commit is contained in:
@@ -1,44 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import Background from "./Background.vue";
|
||||
import Menus from "./Menus/Menus.vue";
|
||||
import OptionsStartUp from "./Menus/Options/StartUp.vue";
|
||||
import OptionsLanguage from "./Menus/Options/Language.vue";
|
||||
import OptionsGbaMode from "./Menus/Options/GbaMode.vue";
|
||||
|
||||
const store = useSettingsStore();
|
||||
|
||||
const viewComponents: Record<string, Component> = {
|
||||
optionsStartUp: OptionsStartUp,
|
||||
optionsLanguage: OptionsLanguage,
|
||||
optionsGbaMode: OptionsGbaMode,
|
||||
};
|
||||
|
||||
const currentViewComponent = computed(() => {
|
||||
if (store.currentView === "menu" || !store.currentView) return null;
|
||||
return viewComponents[store.currentView] || null;
|
||||
});
|
||||
|
||||
const handleBackNavigation = (event: KeyboardEvent) => {
|
||||
if (event.key === "Escape" || event.key === "Backspace") {
|
||||
if (store.navigationStack.length > 0) {
|
||||
store.popNavigation();
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
store.$reset();
|
||||
window.addEventListener("keydown", handleBackNavigation);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener("keydown", handleBackNavigation);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Background />
|
||||
<Menus v-if="store.currentView === 'menu'" />
|
||||
<component :is="currentViewComponent" v-else-if="currentViewComponent" />
|
||||
<Menus />
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user