feat: remove query based routing
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user