Do not use useStorage for root state

This commit is contained in:
2022-02-11 22:03:26 +00:00
parent 45389e01be
commit f6cb6d4163
3 changed files with 30 additions and 20 deletions

View File

@@ -2,21 +2,27 @@ import { useStorage } from "@vueuse/core";
import { defineStore } from "pinia";
interface State {
ShowMenu: boolean | null,
ExpandMenu: boolean,
Menu: MenuSettings
}
interface MenuSettings {
Show: boolean | null,
Expand: boolean | null,
}
export const useSettingsStore = defineStore('settings', {
state: () => useStorage<State>('settings', {
ShowMenu: null,
ExpandMenu: false,
state: () => ({
Menu: useStorage<MenuSettings>('settings', {
Show: null,
Expand: false,
}),
}),
actions: {
toggleMenu() {
this.ShowMenu = !this.ShowMenu;
this.Menu.Show = !this.Menu.Show;
},
toggleMenuSize() {
this.ExpandMenu = !this.ExpandMenu;
this.Menu.Expand = !this.Menu.Expand;
},
}
});