perf: update directly after selecting an avatar (#619)

pull/631/head
wxyShine 2022-09-25 22:02:14 +08:00 committed by GitHub
parent 1b225858bb
commit 205fa09960
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -520,9 +520,21 @@ export default {
this.$refs.avatarInput.focus()
})
},
handleUpdateAvatar() {
this.userForm.model.avatar = this.updateAvatarForm.avatar
this.updateAvatarForm.visible = false
async handleUpdateAvatar() {
const { updateAvatarData } = await apiClient.user.getProfile()
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
})
}
}
}