1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
| import {defineStore} from "pinia";
| import {setStorage} from "@/utils/storage";
|
| export interface AppState {
| sidebar: {
| opened: boolean,
| withoutAnimation: boolean
| },
| device: string,
| size: string
| }
|
| export const useAppStore = defineStore('app',{
| state: ():AppState =>({
| sidebar:{
| opened:true,
| withoutAnimation: false
| },
| device: 'desktop',
| size: 'default'
| }),
| actions:{
| toggleSideBar(){
| this.sidebar.opened = !this.sidebar.opened;
| this.sidebar.withoutAnimation = false;
| if (this.sidebar.opened) {
| setStorage({name:'sidebarStatus',content:'1'})
| }else{
| setStorage({name:'sidebarStatus',content:'0'})
| }
| },
| closeSideBar(withoutAnimation:boolean){
| setStorage({name:'sidebarStatus',content:'0'})
| this.sidebar.opened = false;
| this.sidebar.withoutAnimation = withoutAnimation;
| },
| toggleDevice(device:string) {
| this.device = device;
| },
| setSize(size:string){
| this.size = size;
| }
| },
| persist:{
| pick: ["size"]
| }
| })
|
|