feat(settings): improve typing

This commit is contained in:
2025-12-30 00:45:13 +01:00
parent 6beba85afa
commit 7ac929cf0d
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", {
state: () => ({
currentMenu: null as Menu | null,
currentSubMenu: null as string | null,
currentMenu: null as SettingsMenu | null,
currentSubMenu: null as SettingsSubMenu | null,
menuExpanded: false,
}),
actions: {
openMenu(menu: Menu, expanded: boolean = false) {
openMenu(menu: SettingsMenu, expanded: boolean = false) {
this.currentMenu = menu;
this.menuExpanded = expanded;
this.currentSubMenu = null;
},
openSubMenu(submenu: string) {
openSubMenu(submenu: SettingsSubMenu) {
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];