Feat: add persistentSettingsStore using LocalStorage plugin

This commit is contained in:
2024-05-19 18:44:37 +02:00
parent 658add7888
commit 2aac51a018
2 changed files with 3 additions and 25 deletions
+3 -15
View File
@@ -3,24 +3,12 @@ import { defineStore } from "pinia";
const CARDS_COOKIE_NAME = 'cards_type';
const CARDS_DEFAULT_VALUE = 'heron';
export function getCardsType(): ReturnType<typeof useCookie>{
const cookie = useCookie(CARDS_COOKIE_NAME)
if (!cookie.value) {
cookie.value = CARDS_DEFAULT_VALUE;
}
return cookie;
}
export const useSettingsStore = defineStore("settingstore", {
state: () => ({
cardStyle: "heron" as string,
cardStyle: "heron",
shaderQuality: 6,
shaderFramerate: 60,
}),
actions: {
changeCardStyle(style: string) {
this.cardStyle = style;
getCardsType().value = style;
}
},
persist: true
});