Files
dvcp_v2_webapp/examples/store/index.js
aixianling a8dff862d2 初始化
2021-12-14 18:36:19 +08:00

51 lines
926 B
JavaScript

import Vue from 'vue'
import Vuex from 'vuex'
import preState from 'vuex-persistedstate'
Vue.use(Vuex)
const user = {
state: {
info: {},
ATime:''
},
mutations: {
setUserInfo(state, userInfo) {
state.info = userInfo
},
SET_TIME(state, pay){
state.ATime=pay
}
}
}
export default new Vuex.Store({
state: {
dicts: [],
apps: []
},
mutations: {
setDicts(state, payload) {
if (payload) {
payload.map(p => {
if (state.dicts.some(d => d.key == p.key)) {
const index = state.dicts.findIndex(d => d.key == p.key)
state.dicts.splice(index, 1)
state.dicts.push(p)
} else {
state.dicts.push(p)
}
})
}
},
addApp(state, app) {
state.apps.push(app)
},
cleanApps(state) {
state.apps = []
}
},
modules: {user},
plugins: [preState()]
})