mirror of https://github.com/halo-dev/halo-admin
perf: update directly after selecting an avatar (#619)
parent
1b225858bb
commit
205fa09960
|
@ -520,9 +520,21 @@ export default {
|
||||||
this.$refs.avatarInput.focus()
|
this.$refs.avatarInput.focus()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleUpdateAvatar() {
|
async handleUpdateAvatar() {
|
||||||
this.userForm.model.avatar = this.updateAvatarForm.avatar
|
const { updateAvatarData } = await apiClient.user.getProfile()
|
||||||
this.updateAvatarForm.visible = false
|
updateAvatarData.avatar = this.updateAvatarForm.avatar
|
||||||
|
apiClient.user
|
||||||
|
.updateProfile(updateAvatarData)
|
||||||
|
.then(response => {
|
||||||
|
this.$message.success('更新头像成功!')
|
||||||
|
this.updateAvatarForm.visible = false
|
||||||
|
this.userForm.model.avatar = response.data.avatar
|
||||||
|
this.setUser(Object.assign({}, this.userForm.model))
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message.error('更新头像失败!')
|
||||||
|
this.updateAvatarForm.visible = true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue