import Vue from 'vue' import { SIDEBAR_TYPE, DEFAULT_THEME, DEFAULT_COLOR, DEFAULT_COLOR_WEAK } from "@/store/mutation-types" const app = { state: { sidebar: { opened: true, withoutAnimation: false }, device: 'desktop', theme: '', color: null, weak: false }, mutations: { SET_SIDEBAR_TYPE: (state, type) => { state.sidebar.opened = type Vue.ls.set(SIDEBAR_TYPE, type) }, CLOSE_SIDEBAR: (state, withoutAnimation) => { Vue.ls.set(SIDEBAR_TYPE, true) state.sidebar.opened = false state.sidebar.withoutAnimation = withoutAnimation }, TOGGLE_DEVICE: (state, device) => { state.device = device }, TOGGLE_THEME: (state, theme) => { // setStore('_DEFAULT_THEME', theme) Vue.ls.set(DEFAULT_THEME, theme) state.theme = theme }, TOGGLE_COLOR: (state, color) => { Vue.ls.set(DEFAULT_COLOR, color) state.color = color }, TOGGLE_WEAK: (state, flag) => { Vue.ls.set(DEFAULT_COLOR_WEAK, flag) state.weak = flag } }, actions: { setSidebar: ({ commit }, type) => { commit('SET_SIDEBAR_TYPE', type) }, CloseSidebar({ commit }, { withoutAnimation }) { commit('CLOSE_SIDEBAR', withoutAnimation) }, ToggleDevice({ commit }, device) { commit('TOGGLE_DEVICE', device) }, ToggleTheme({ commit }, theme) { commit('TOGGLE_THEME', theme) }, ToggleColor({ commit }, color) { commit('TOGGLE_COLOR', color) }, ToggleWeak({ commit }, weakFlag) { commit('TOGGLE_WEAK', weakFlag) } } } export default app