store.js
534 Bytes
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
profile: null,
},
mutations: {
basicMutation(state, payload) {
Object.assign(state, payload);
},
},
actions: {
// 获取用户身份
async getProfile({
commit
}, payload) {
let res = await app.get({
url: app.api.profile,
data: {},
opt: {
toast: false
}
})
commit('basicMutation', {
profile: res
})
},
}
})