27 lines
625 B
TypeScript
27 lines
625 B
TypeScript
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,
|
|
}),
|
|
|
|
actions: {
|
|
changeCardStyle(style: string) {
|
|
this.cardStyle = style;
|
|
getCardsType().value = style;
|
|
}
|
|
},
|
|
persist: true
|
|
});
|