blob: f4872415801e20418c1fa1d010508ad78928795f [file] [log] [blame]
huibing.xie1f1606f2018-08-20 15:46:55 +08001import Cookies from 'js-cookie'
2
3const app = {
4 state: {
5 sidebar: {
6 opened: !+Cookies.get('sidebarStatus'),
7 withoutAnimation: false
8 },
9 device: 'desktop'
10 },
11 mutations: {
12 TOGGLE_SIDEBAR: state => {
13 if (state.sidebar.opened) {
14 Cookies.set('sidebarStatus', 1)
15 } else {
16 Cookies.set('sidebarStatus', 0)
17 }
18 state.sidebar.opened = !state.sidebar.opened
19 state.sidebar.withoutAnimation = false
20 },
21 CLOSE_SIDEBAR: (state, withoutAnimation) => {
22 Cookies.set('sidebarStatus', 1)
23 state.sidebar.opened = false
24 state.sidebar.withoutAnimation = withoutAnimation
25 },
26 TOGGLE_DEVICE: (state, device) => {
27 state.device = device
28 }
29 },
30 actions: {
31 ToggleSideBar: ({ commit }) => {
32 commit('TOGGLE_SIDEBAR')
33 },
34 CloseSideBar({ commit }, { withoutAnimation }) {
35 commit('CLOSE_SIDEBAR', withoutAnimation)
36 },
37 ToggleDevice({ commit }, device) {
38 commit('TOGGLE_DEVICE', device)
39 }
40 }
41}
42
43export default app