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 = { |
const state = { |
||||
sidebar: { |
sidebar: { |
||||
opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, |
opened: Cookies.get("sidebarStatus") |
||||
|
? !!+Cookies.get("sidebarStatus") |
||||
|
: true, |
||||
withoutAnimation: false, |
withoutAnimation: false, |
||||
hide: false |
hide: false, |
||||
}, |
}, |
||||
device: 'desktop', |
device: "desktop", |
||||
size: Cookies.get('size') || 'medium' |
size: Cookies.get("size") || "medium", |
||||
} |
}; |
||||
|
|
||||
const mutations = { |
const mutations = { |
||||
TOGGLE_SIDEBAR: state => { |
TOGGLE_SIDEBAR: (state) => { |
||||
if (state.sidebar.hide) { |
if (state.sidebar.hide) { |
||||
return false; |
return true; |
||||
} |
} |
||||
state.sidebar.opened = !state.sidebar.opened |
state.sidebar.opened = true; |
||||
state.sidebar.withoutAnimation = false |
state.sidebar.withoutAnimation = true; |
||||
if (state.sidebar.opened) { |
if (state.sidebar.opened) { |
||||
Cookies.set('sidebarStatus', 1) |
Cookies.set("sidebarStatus", 1); |
||||
} else { |
} else { |
||||
Cookies.set('sidebarStatus', 0) |
Cookies.set("sidebarStatus", 1); |
||||
} |
} |
||||
}, |
}, |
||||
CLOSE_SIDEBAR: (state, withoutAnimation) => { |
CLOSE_SIDEBAR: (state, withoutAnimation) => { |
||||
Cookies.set('sidebarStatus', 0) |
Cookies.set("sidebarStatus", 1); |
||||
state.sidebar.opened = false |
state.sidebar.opened = true; |
||||
state.sidebar.withoutAnimation = withoutAnimation |
state.sidebar.withoutAnimation = false; |
||||
}, |
}, |
||||
TOGGLE_DEVICE: (state, device) => { |
TOGGLE_DEVICE: (state, device) => { |
||||
state.device = device |
state.device = device; |
||||
}, |
}, |
||||
SET_SIZE: (state, size) => { |
SET_SIZE: (state, size) => { |
||||
state.size = size |
state.size = size; |
||||
Cookies.set('size', size) |
Cookies.set("size", size); |
||||
}, |
}, |
||||
SET_SIDEBAR_HIDE: (state, status) => { |
SET_SIDEBAR_HIDE: (state, status) => { |
||||
state.sidebar.hide = status |
state.sidebar.hide = status; |
||||
} |
}, |
||||
} |
}; |
||||
|
|
||||
const actions = { |
const actions = { |
||||
toggleSideBar({ commit }) { |
toggleSideBar({ commit }) { |
||||
commit('TOGGLE_SIDEBAR') |
commit("TOGGLE_SIDEBAR"); |
||||
}, |
}, |
||||
closeSideBar({ commit }, { withoutAnimation }) { |
closeSideBar({ commit }, { withoutAnimation }) { |
||||
commit('CLOSE_SIDEBAR', withoutAnimation) |
commit("CLOSE_SIDEBAR", withoutAnimation); |
||||
}, |
}, |
||||
toggleDevice({ commit }, device) { |
toggleDevice({ commit }, device) { |
||||
commit('TOGGLE_DEVICE', device) |
commit("TOGGLE_DEVICE", device); |
||||
}, |
}, |
||||
setSize({ commit }, size) { |
setSize({ commit }, size) { |
||||
commit('SET_SIZE', size) |
commit("SET_SIZE", size); |
||||
}, |
}, |
||||
toggleSideBarHide({ commit }, status) { |
toggleSideBarHide({ commit }, status) { |
||||
commit('SET_SIDEBAR_HIDE', status) |
commit("SET_SIDEBAR_HIDE", status); |
||||
} |
}, |
||||
} |
}; |
||||
|
|
||||
export default { |
export default { |
||||
namespaced: true, |
namespaced: true, |
||||
state, |
state, |
||||
mutations, |
mutations, |
||||
actions |
actions, |
||||
} |
}; |
||||
|
Loading…
Reference in new issue