/* * @Author: your name * @Date: 2021-10-14 17:17:53 * @LastEditTime: 2022-02-14 17:19:26 * @LastEditors: your name * @Description: In User Settings Edit * @FilePath: \Foshan4A\src\store\modules\app.js */ import Cookies from 'js-cookie' const state = { sidebar: { opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, withoutAnimation: false }, device: 'desktop', dialog: Cookies.get('dialogStatus') === 'true' ? true : false, pwdflag: false, outflag: false, outcheck: false, systemSet: Cookies.get('systemSet') != null ? Cookies.get('systemSet') : null, } const mutations = { TOGGLE_SIDEBAR: state => { state.sidebar.opened = !state.sidebar.opened state.sidebar.withoutAnimation = false if (state.sidebar.opened) { Cookies.set('sidebarStatus', 1) } else { Cookies.set('sidebarStatus', 0) } }, CLOSE_SIDEBAR: (state, withoutAnimation) => { Cookies.set('sidebarStatus', 0) state.sidebar.opened = false state.sidebar.withoutAnimation = withoutAnimation }, TOGGLE_DEVICE: (state, device) => { state.device = device }, TOGGLE_DIALOG: (state, dialog) => { state.dialog = dialog Cookies.set('dialogStatus', dialog) }, TOGGLE_PWDFLAG: (state, pwdflag) => { state.pwdflag = pwdflag }, TOGGLE_OUTFLAG: (state, outflag) => { state.outflag = outflag }, TOGGLE_OUTCHECK: (state, outcheck) => { state.outcheck = outcheck }, SYSTEM_SET: (state, systemSet) => { state.systemSet = systemSet Cookies.set('systemSet', systemSet) } } const actions = { toggleSideBar ({ commit }) { commit('TOGGLE_SIDEBAR') }, closeSideBar ({ commit }, { withoutAnimation }) { commit('CLOSE_SIDEBAR', withoutAnimation) }, toggleDevice ({ commit }, device) { commit('TOGGLE_DEVICE', device) }, toggleDialog ({ commit }, dialog) { commit('TOGGLE_DIALOG', dialog) }, togglePwdflag ({ commit }, pwdflag) { commit('TOGGLE_PWDFLAG', pwdflag) }, toggleOutflag ({ commit }, outflag) { commit('TOGGLE_OUTFLAG', outflag) }, toggleOutcheck ({ commit }, outcheck) { commit('TOGGLE_OUTCHECK', outcheck) }, getSystemSet({ commit }, systemSet) { commit('SYSTEM_SET', systemSet) } } export default { namespaced: true, state, mutations, actions }