feat: remove query based routing

This commit is contained in:
2025-12-29 19:47:01 +01:00
parent e912270d1e
commit 96f8d5093b
14 changed files with 207 additions and 140 deletions

View File

@@ -15,36 +15,35 @@ const defaultSettings = (): Settings => ({
color: { col: 0, row: 0 },
});
const loadSettings = (): Settings => {
const stored = localStorage.getItem(STORAGE_ID);
try {
const result = settingsSchema.safeParse(JSON.parse(stored ?? ""));
if (result.success) {
return result.data;
}
} catch {
// JSON.parse failed
}
const settings = defaultSettings();
saveSettings(settings);
return settings;
};
const saveSettings = (settings: Settings) => {
localStorage.setItem(STORAGE_ID, JSON.stringify(settings));
};
export const useAppStore = defineStore("app", {
state: () => ({
booted: false,
settings: loadSettings(),
}),
state: () => {
let settings: Settings;
const stored = localStorage.getItem(STORAGE_ID);
try {
settings = settingsSchema.parse(JSON.parse(stored ?? ""));
} catch {
settings = defaultSettings();
}
return {
booted: false,
settings,
screen: "home" as AppScreen,
};
},
actions: {
setColor(col: number, row: number) {
this.settings.color = { col, row };
},
navigateTo(screen: AppScreen) {
this.screen = screen;
},
save() {
localStorage.setItem(STORAGE_ID, JSON.stringify(this.settings));
},
},
getters: {