4 changed files with 49 additions and 47 deletions
@ -1,66 +1,68 @@ |
|||
import Cookies from 'js-cookie' |
|||
import Cookies from "js-cookie"; |
|||
|
|||
const state = { |
|||
sidebar: { |
|||
opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, |
|||
opened: Cookies.get("sidebarStatus") |
|||
? !!+Cookies.get("sidebarStatus") |
|||
: true, |
|||
withoutAnimation: false, |
|||
hide: false |
|||
hide: false, |
|||
}, |
|||
device: 'desktop', |
|||
size: Cookies.get('size') || 'medium' |
|||
} |
|||
device: "desktop", |
|||
size: Cookies.get("size") || "medium", |
|||
}; |
|||
|
|||
const mutations = { |
|||
TOGGLE_SIDEBAR: state => { |
|||
TOGGLE_SIDEBAR: (state) => { |
|||
if (state.sidebar.hide) { |
|||
return false; |
|||
return true; |
|||
} |
|||
state.sidebar.opened = !state.sidebar.opened |
|||
state.sidebar.withoutAnimation = false |
|||
state.sidebar.opened = true; |
|||
state.sidebar.withoutAnimation = true; |
|||
if (state.sidebar.opened) { |
|||
Cookies.set('sidebarStatus', 1) |
|||
Cookies.set("sidebarStatus", 1); |
|||
} else { |
|||
Cookies.set('sidebarStatus', 0) |
|||
Cookies.set("sidebarStatus", 1); |
|||
} |
|||
}, |
|||
CLOSE_SIDEBAR: (state, withoutAnimation) => { |
|||
Cookies.set('sidebarStatus', 0) |
|||
state.sidebar.opened = false |
|||
state.sidebar.withoutAnimation = withoutAnimation |
|||
Cookies.set("sidebarStatus", 1); |
|||
state.sidebar.opened = true; |
|||
state.sidebar.withoutAnimation = false; |
|||
}, |
|||
TOGGLE_DEVICE: (state, device) => { |
|||
state.device = device |
|||
state.device = device; |
|||
}, |
|||
SET_SIZE: (state, size) => { |
|||
state.size = size |
|||
Cookies.set('size', size) |
|||
state.size = size; |
|||
Cookies.set("size", size); |
|||
}, |
|||
SET_SIDEBAR_HIDE: (state, status) => { |
|||
state.sidebar.hide = status |
|||
} |
|||
} |
|||
state.sidebar.hide = status; |
|||
}, |
|||
}; |
|||
|
|||
const actions = { |
|||
toggleSideBar({ commit }) { |
|||
commit('TOGGLE_SIDEBAR') |
|||
commit("TOGGLE_SIDEBAR"); |
|||
}, |
|||
closeSideBar({ commit }, { withoutAnimation }) { |
|||
commit('CLOSE_SIDEBAR', withoutAnimation) |
|||
commit("CLOSE_SIDEBAR", withoutAnimation); |
|||
}, |
|||
toggleDevice({ commit }, device) { |
|||
commit('TOGGLE_DEVICE', device) |
|||
commit("TOGGLE_DEVICE", device); |
|||
}, |
|||
setSize({ commit }, size) { |
|||
commit('SET_SIZE', size) |
|||
commit("SET_SIZE", size); |
|||
}, |
|||
toggleSideBarHide({ commit }, status) { |
|||
commit('SET_SIDEBAR_HIDE', status) |
|||
} |
|||
} |
|||
commit("SET_SIDEBAR_HIDE", status); |
|||
}, |
|||
}; |
|||
|
|||
export default { |
|||
namespaced: true, |
|||
state, |
|||
mutations, |
|||
actions |
|||
} |
|||
actions, |
|||
}; |
|||
|
Loading…
Reference in new issue