user.js
566 Bytes
import { getUserInfo } from '@/api/user'
const state = {
name: '',
avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
}
const mutations = {
SET_NAME: (state, name) => {
state.name = name
}
}
const actions = {
getUserInfo ({ commit }) {
return new Promise(async (resolve) => {
let { result: res } = await getUserInfo()
commit('SET_NAME', res.loginName)
resolve(true)
})
},
}
export default {
namespaced: true,
state,
mutations,
actions
}