Skip to content

Commit

Permalink
优化头像上传参数新增文件名称
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzongzhuan committed Nov 29, 2023
1 parent adec3f0 commit 0037e65
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions ruoyi-ui/src/views/system/user/profile/userAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ export default {
// 弹出层标题
title: "修改头像",
options: {
img: store.getters.avatar, //裁剪图片的地址
autoCrop: true, // 是否默认生成截图框
autoCropWidth: 200, // 默认生成截图框宽度
autoCropHeight: 200, // 默认生成截图框高度
fixedBox: true, // 固定截图框大小 不允许改变
outputType:"png" // 默认生成截图为PNG格式
img: store.getters.avatar, //裁剪图片的地址
autoCrop: true, // 是否默认生成截图框
autoCropWidth: 200, // 默认生成截图框宽度
autoCropHeight: 200, // 默认生成截图框高度
fixedBox: true, // 固定截图框大小 不允许改变
outputType:"png", // 默认生成截图为PNG格式
filename: 'avatar' // 文件名称
},
previews: {},
resizeHandler: null
Expand Down Expand Up @@ -125,14 +126,15 @@ export default {
reader.readAsDataURL(file);
reader.onload = () => {
this.options.img = reader.result;
this.options.filename = file.name;
};
}
},
// 上传图片
uploadImg() {
this.$refs.cropper.getCropBlob(data => {
let formData = new FormData();
formData.append("avatarfile", data);
formData.append("avatarfile", data, this.options.filename);
uploadAvatar(formData).then(response => {
this.open = false;
this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl;
Expand Down

0 comments on commit 0037e65

Please sign in to comment.