feat(settings): improve typing

This commit is contained in:
2025-12-30 00:45:13 +01:00
parent 4689b33d3d
commit 9f3ebb1430
2 changed files with 21 additions and 6 deletions

View File

@@ -1,20 +1,18 @@
type Menu = "options" | "clock" | "user" | "touchScreen";
export const useSettingsStore = defineStore("settings", { export const useSettingsStore = defineStore("settings", {
state: () => ({ state: () => ({
currentMenu: null as Menu | null, currentMenu: null as SettingsMenu | null,
currentSubMenu: null as string | null, currentSubMenu: null as SettingsSubMenu | null,
menuExpanded: false, menuExpanded: false,
}), }),
actions: { actions: {
openMenu(menu: Menu, expanded: boolean = false) { openMenu(menu: SettingsMenu, expanded: boolean = false) {
this.currentMenu = menu; this.currentMenu = menu;
this.menuExpanded = expanded; this.menuExpanded = expanded;
this.currentSubMenu = null; this.currentSubMenu = null;
}, },
openSubMenu(submenu: string) { openSubMenu(submenu: SettingsSubMenu) {
this.currentSubMenu = submenu; this.currentSubMenu = submenu;
}, },

17
app/utils/settings.ts Normal file
View File

@@ -0,0 +1,17 @@
export const SETTINGS_MENUS = ["options", "clock", "user", "touchScreen"] as const;
export const SETTINGS_SUB_MENUS = [
"optionsLanguage",
"optionsGbaMode",
"optionsStartUp",
"clockAlarm",
"clockTime",
"clockDate",
"userBirthday",
"userName",
"userMessage",
"userColor",
] as const;
export type SettingsMenu = (typeof SETTINGS_MENUS)[number];
export type SettingsSubMenu = (typeof SETTINGS_SUB_MENUS)[number];