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;