diff --git a/vue/src/api/system/user.js b/vue/src/api/system/user.js index ae9457a..2d2cd88 100644 --- a/vue/src/api/system/user.js +++ b/vue/src/api/system/user.js @@ -39,7 +39,7 @@ export function updateUserPwd(data) { } export function updateAvatar(key) { - return request.get(baseUrl + '/updateAvatar?key=' + encodeURIComponent(key)).then(({data}) => data) + return request.get(baseUrl + '/updateAvatar?key=' + encodeURIComponent(key)).then(({data}) => ({...data, key})) } export function validate(pwd) { diff --git a/vue/src/assets/styles/index.scss b/vue/src/assets/styles/index.scss index eb36973..a573051 100644 --- a/vue/src/assets/styles/index.scss +++ b/vue/src/assets/styles/index.scss @@ -96,6 +96,16 @@ a:hover { margin-top: 10px; } +.table-image { + cursor: pointer; + display: inline-block; + height: 32px; + width: 32px; + border-radius: 50%; + vertical-align: middle; + overflow: hidden; +} + .card-container { position: relative; diff --git a/vue/src/utils/file.js b/vue/src/utils/file.js index d4a7038..084b8d0 100644 --- a/vue/src/utils/file.js +++ b/vue/src/utils/file.js @@ -41,7 +41,7 @@ export function upload(blob, filename = '快照.png') { param.append('file', blob, filename) return request.post(attachmentUploadUrl, param, {...formConfig, baseUrl: ''}) }) - .then(data => data.key) + .then(({data}) => data.key) } //自动补全附件链接前缀 diff --git a/vue/src/views/system/user/index.vue b/vue/src/views/system/user/index.vue index e95ddc0..4815494 100644 --- a/vue/src/views/system/user/index.vue +++ b/vue/src/views/system/user/index.vue @@ -44,9 +44,13 @@ > - + @@ -206,6 +210,9 @@ elSuccess(msg) this.editDialog = false this.search() + }, + previewAvatar(src) { + this.$image({index: 0, urlList: [src]}) } } } diff --git a/vue/src/views/userCenter/components/Avatar.vue b/vue/src/views/userCenter/components/Avatar.vue index b7b1cf3..93593ae 100644 --- a/vue/src/views/userCenter/components/Avatar.vue +++ b/vue/src/views/userCenter/components/Avatar.vue @@ -78,15 +78,11 @@ if (!this.img) return elError('请先上传图片') if (this.loading) return this.loading = true - let url this.$refs.cropper.getCropBlob(data => { upload(new Blob([data]), this.name) - .then(key => { - url = key - return updateAvatar(key) - }) - .then(({msg}) => { - this.$store.commit('user/SET_AVATAR', autoCompleteUrl(url)) + .then(key => updateAvatar(key)) + .then(({key, msg}) => { + this.$store.commit('user/SET_AVATAR', autoCompleteUrl(key)) this.$store.dispatch('user/refresh') elSuccess(msg) })