From 01e8fe5ddb510b0abeb9e4f1e828a5f8d43f7d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Wed, 4 Aug 2021 13:10:28 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=A4=B4=E5=83=8F=E4=B8=8A=E4=BC=A0=20?= =?UTF-8?q?=E6=9C=AA=E8=B5=B0OSS=E5=AD=98=E5=82=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/store/modules/user.js | 2 +- ruoyi-ui/src/views/system/user/profile/userAvatar.vue | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ruoyi-ui/src/store/modules/user.js b/ruoyi-ui/src/store/modules/user.js index c6624e3a..917f9163 100644 --- a/ruoyi-ui/src/store/modules/user.js +++ b/ruoyi-ui/src/store/modules/user.js @@ -51,7 +51,7 @@ const user = { return new Promise((resolve, reject) => { getInfo().then(res => { const user = res.data.user - const avatar = user.avatar == "" ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar; + const avatar = user.avatar == "" ? require("@/assets/images/profile.jpg") : user.avatar; if (res.data.roles && res.data.roles.length > 0) { // 验证返回的roles是否是一个非空数组 commit('SET_ROLES', res.data.roles) commit('SET_PERMISSIONS', res.data.permissions) diff --git a/ruoyi-ui/src/views/system/user/profile/userAvatar.vue b/ruoyi-ui/src/views/system/user/profile/userAvatar.vue index f20c9226..3d1b9ef2 100644 --- a/ruoyi-ui/src/views/system/user/profile/userAvatar.vue +++ b/ruoyi-ui/src/views/system/user/profile/userAvatar.vue @@ -77,7 +77,8 @@ export default { autoCrop: true, // 是否默认生成截图框 autoCropWidth: 200, // 默认生成截图框宽度 autoCropHeight: 200, // 默认生成截图框高度 - fixedBox: true // 固定截图框大小 不允许改变 + fixedBox: true, // 固定截图框大小 不允许改变 + filename: '' }, previews: {} }; @@ -116,6 +117,7 @@ export default { reader.readAsDataURL(file); reader.onload = () => { this.options.img = reader.result; + this.options.filename = file.name; }; } }, @@ -123,7 +125,8 @@ export default { uploadImg() { this.$refs.cropper.getCropBlob(data => { let formData = new FormData(); - formData.append("avatarfile", data); + console.log(this.options.filename) + formData.append("avatarfile", data, this.options.filename); uploadAvatar(formData).then(response => { this.open = false; this.options.img = response.data.imgUrl;