|
1
|
import Cookies from 'js-cookie'
|
|
2
3
4
|
const state = {
sidebar: {
|
|
5
6
|
opened: Cookies.get('sidebarStatus')
? !!+Cookies.get('sidebarStatus')
|
|
7
|
: true,
|
|
8
|
withoutAnimation: false
|
|
9
|
},
|
|
10
11
|
device: 'desktop'
}
|
|
12
13
|
const mutations = {
|
|
14
|
TOGGLE_SIDEBAR: (state) => {
|
|
15
16
|
state.sidebar.opened = !state.sidebar.opened
state.sidebar.withoutAnimation = false
|
|
17
|
if (state.sidebar.opened) {
|
|
18
|
Cookies.set('sidebarStatus', 1)
|
|
19
|
} else {
|
|
20
|
Cookies.set('sidebarStatus', 0)
|
|
21
22
23
|
}
},
CLOSE_SIDEBAR: (state, withoutAnimation) => {
|
|
24
25
26
|
Cookies.set('sidebarStatus', 0)
state.sidebar.opened = false
state.sidebar.withoutAnimation = withoutAnimation
|
|
27
28
|
},
TOGGLE_DEVICE: (state, device) => {
|
|
29
30
31
|
state.device = device
}
}
|
|
32
33
34
|
const actions = {
toggleSideBar({ commit }) {
|
|
35
|
commit('TOGGLE_SIDEBAR')
|
|
36
37
|
},
closeSideBar({ commit }, { withoutAnimation }) {
|
|
38
|
commit('CLOSE_SIDEBAR', withoutAnimation)
|
|
39
40
|
},
toggleDevice({ commit }, device) {
|
|
41
42
43
|
commit('TOGGLE_DEVICE', device)
}
}
|
|
44
45
46
47
48
|
export default {
namespaced: true,
state,
mutations,
|
|
49
50
|
actions
}
|