41 lines
772 B
JavaScript
41 lines
772 B
JavaScript
import Vue from 'vue'
|
|
import Vuex from 'vuex'
|
|
|
|
Vue.use(Vuex)
|
|
|
|
export default new Vuex.Store({
|
|
state: {
|
|
// 用户信息
|
|
user_info: {},
|
|
// 配置信息
|
|
settings: {},
|
|
},
|
|
mutations: {
|
|
// 设置用户信息
|
|
SET_USERINFO(state, user_info) {
|
|
state.user_info = user_info;
|
|
},
|
|
// 设置配置信息
|
|
SET_SETTINGS(state, settings) {
|
|
state.settings = settings;
|
|
},
|
|
},
|
|
actions: {
|
|
// 设置用户信息
|
|
setUserInfo({
|
|
commit
|
|
}, arg) {
|
|
commit('SET_USERINFO', arg[0]);
|
|
localStorage.setItem("storeState", JSON.stringify(arg[1].$store.state));
|
|
},
|
|
// 设置配置信息
|
|
setSettings({
|
|
commit
|
|
}, arg) {
|
|
commit('SET_SETTINGS', arg[0]);
|
|
localStorage.setItem("storeState", JSON.stringify(arg[1].$store.state));
|
|
},
|
|
},
|
|
modules: {}
|
|
})
|