管理系统PC前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dm-manage-web/src/store/modules/app.js

67 lines
1.5 KiB

2 years ago
import Cookies from 'js-cookie';
2 years ago
const state = {
sidebar: {
opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
withoutAnimation: false,
hide: false
},
device: 'desktop',
size: Cookies.get('size') || 'medium'
2 years ago
};
2 years ago
const mutations = {
2 years ago
TOGGLE_SIDEBAR: (state) => {
2 years ago
if (state.sidebar.hide) {
return false;
}
2 years ago
state.sidebar.opened = !state.sidebar.opened;
state.sidebar.withoutAnimation = false;
2 years ago
if (state.sidebar.opened) {
2 years ago
Cookies.set('sidebarStatus', 1);
2 years ago
} else {
2 years ago
Cookies.set('sidebarStatus', 0);
2 years ago
}
},
CLOSE_SIDEBAR: (state, withoutAnimation) => {
2 years ago
Cookies.set('sidebarStatus', 0);
state.sidebar.opened = false;
state.sidebar.withoutAnimation = withoutAnimation;
2 years ago
},
TOGGLE_DEVICE: (state, device) => {
2 years ago
state.device = device;
2 years ago
},
SET_SIZE: (state, size) => {
2 years ago
state.size = size;
Cookies.set('size', size);
2 years ago
},
SET_SIDEBAR_HIDE: (state, status) => {
2 years ago
state.sidebar.hide = status;
2 years ago
}
2 years ago
};
2 years ago
const actions = {
toggleSideBar({ commit }) {
2 years ago
commit('TOGGLE_SIDEBAR');
2 years ago
},
closeSideBar({ commit }, { withoutAnimation }) {
2 years ago
commit('CLOSE_SIDEBAR', withoutAnimation);
2 years ago
},
toggleDevice({ commit }, device) {
2 years ago
commit('TOGGLE_DEVICE', device);
2 years ago
},
setSize({ commit }, size) {
2 years ago
commit('SET_SIZE', size);
2 years ago
},
toggleSideBarHide({ commit }, status) {
2 years ago
commit('SET_SIDEBAR_HIDE', status);
2 years ago
}
2 years ago
};
2 years ago
export default {
namespaced: true,
state,
mutations,
actions
2 years ago
};