Feat: add persistentSettingsStore using LocalStorage plugin
This commit is contained in:
@@ -1,10 +0,0 @@
|
|||||||
const CARDS_COOKIE_NAME = 'cards_type';
|
|
||||||
const CARDS_DEFAULT_VALUE = 'heron';
|
|
||||||
|
|
||||||
export function getCardsType(): CookieRef<string | null | undefined> {
|
|
||||||
const cookie = useCookie(CARDS_COOKIE_NAME)
|
|
||||||
if (!cookie.value) {
|
|
||||||
cookie.value = CARDS_DEFAULT_VALUE;
|
|
||||||
}
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
+3
-15
@@ -3,24 +3,12 @@ import { defineStore } from "pinia";
|
|||||||
const CARDS_COOKIE_NAME = 'cards_type';
|
const CARDS_COOKIE_NAME = 'cards_type';
|
||||||
const CARDS_DEFAULT_VALUE = 'heron';
|
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", {
|
export const useSettingsStore = defineStore("settingstore", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
cardStyle: "heron" as string,
|
cardStyle: "heron",
|
||||||
|
shaderQuality: 6,
|
||||||
|
shaderFramerate: 60,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
|
||||||
changeCardStyle(style: string) {
|
|
||||||
this.cardStyle = style;
|
|
||||||
getCardsType().value = style;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
persist: true
|
persist: true
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user