baimacms/store/index.js

43 lines
794 B
JavaScript

import { createStore } from 'vuex'
const store = createStore({
state: {
currentUid: '',
relationId: ''
},
getters: {
currentUid: state => state.currentUid,
relationId: state => state.relationId
},
mutations: {
SET_CURRENT_UID(state, uid) {
state.currentUid = uid
},
CLEAR_CURRENT_UID(state) {
state.currentUid = ''
},
SET_RELATION_ID(state, rid) {
state.relationId = rid
},
CLEAR_RELATION_ID(state) {
state.relationId = ''
}
},
actions: {
setCurrentUid({ commit }, uid) {
commit('SET_CURRENT_UID', uid)
},
clearCurrentUid({ commit }) {
commit('CLEAR_CURRENT_UID')
},
setRelationId({ commit }, rid) {
commit('SET_RELATION_ID', rid)
},
clearRelationId({ commit }) {
commit('CLEAR_RELATION_ID')
}
}
})
export default store