疯狂的狮子Li
2023-01-31 771a1045ee3ef382d02b08afb620ef0b34d9d13a
ruoyi-ui/src/views/system/user/profile/userAvatar.vue
@@ -12,6 +12,7 @@
            :autoCropWidth="options.autoCropWidth"
            :autoCropHeight="options.autoCropHeight"
            :fixedBox="options.fixedBox"
            :outputType="options.outputType"
            @realTime="realTime"
            v-if="visible"
          />
@@ -78,7 +79,9 @@
        autoCrop: true, // 是否默认生成截图框
        autoCropWidth: 200, // 默认生成截图框宽度
        autoCropHeight: 200, // 默认生成截图框高度
        fixedBox: true // 固定截图框大小 不允许改变
        fixedBox: true, // 固定截图框大小 不允许改变
        outputType:"png", // 默认生成截图为PNG格式
        filename: ''
      },
      previews: {},
      resizeHandler: null
@@ -128,6 +131,7 @@
        reader.readAsDataURL(file);
        reader.onload = () => {
          this.options.img = reader.result;
          this.options.filename = file.name;
        };
      }
    },
@@ -135,10 +139,11 @@
    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 = process.env.VUE_APP_BASE_API + response.imgUrl;
          this.options.img = response.data.imgUrl;
          store.commit('SET_AVATAR', this.options.img);
          this.$modal.msgSuccess("修改成功");
          this.visible = false;