app.js 1.01 KB
Newer Older
Pan's avatar
Pan committed
1
import Cookies from 'js-cookie'
Pan's avatar
Pan committed
2 3 4 5

const app = {
  state: {
    sidebar: {
6 7 8 9
      opened: !+Cookies.get('sidebarStatus'),
      withoutAnimation: false
    },
    device: 'desktop'
Pan's avatar
Pan committed
10 11 12 13
  },
  mutations: {
    TOGGLE_SIDEBAR: state => {
      if (state.sidebar.opened) {
Pan's avatar
Pan committed
14
        Cookies.set('sidebarStatus', 1)
Pan's avatar
Pan committed
15
      } else {
Pan's avatar
Pan committed
16
        Cookies.set('sidebarStatus', 0)
Pan's avatar
Pan committed
17
      }
Pan's avatar
Pan committed
18
      state.sidebar.opened = !state.sidebar.opened
19
      state.sidebar.withoutAnimation = false
20 21 22 23 24 25 26 27
    },
    CLOSE_SIDEBAR: (state, withoutAnimation) => {
      Cookies.set('sidebarStatus', 1)
      state.sidebar.opened = false
      state.sidebar.withoutAnimation = withoutAnimation
    },
    TOGGLE_DEVICE: (state, device) => {
      state.device = device
Pan's avatar
Pan committed
28 29 30 31 32
    }
  },
  actions: {
    ToggleSideBar: ({ commit }) => {
      commit('TOGGLE_SIDEBAR')
33 34 35 36 37 38
    },
    CloseSideBar({ commit }, { withoutAnimation }) {
      commit('CLOSE_SIDEBAR', withoutAnimation)
    },
    ToggleDevice({ commit }, device) {
      commit('TOGGLE_DEVICE', device)
Pan's avatar
Pan committed
39 40
    }
  }
Pan's avatar
Pan committed
41
}
Pan's avatar
Pan committed
42

Pan's avatar
Pan committed
43
export default app