baimacms/store/index.js

65 lines
1.2 KiB
JavaScript

import { createStore } from 'vuex'
const store = createStore({
state: {
currentUid: '',
relationId: '',
pid: '',
isThirdParty: false
},
getters: {
currentUid: state => state.currentUid,
relationId: state => state.relationId,
pid: state => state.pid,
isThirdParty: state => state.isThirdParty
},
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 = ''
},
SET_PID(state, pid) {
state.pid = pid
},
CLEAR_PID(state) {
state.pid = ''
},
SET_IS_THIRD_PARTY(state, flag) {
state.isThirdParty = flag
}
},
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')
},
setPid({ commit }, pid) {
commit('SET_PID', pid)
},
clearPid({ commit }) {
commit('CLEAR_PID')
},
setIsThirdParty({ commit }, flag) {
commit('SET_IS_THIRD_PARTY', flag)
}
}
})
export default store