yg_admin_fe/src/store/index.js
2020-03-29 18:41:55 +08:00

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: {}
})