疯狂的狮子li
2021-07-23 dd9340090b9d960e486201e92d6a7a991d7cdec6
ruoyi-ui/src/components/ImageUpload/index.vue
@@ -74,7 +74,7 @@
      dialogVisible: false,
      hideUpload: false,
      baseUrl: process.env.VUE_APP_BASE_API,
      uploadImgUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
      uploadImgUrl: process.env.VUE_APP_BASE_API + "/system/oss/upload", // 上传的图片服务器地址
      headers: {
        Authorization: "Bearer " + getToken(),
      },
@@ -90,11 +90,7 @@
          // 然后将数组转为对象数组
          this.fileList = list.map(item => {
            if (typeof item === "string") {
              if (item.indexOf(this.baseUrl) === -1) {
                  item = { name: this.baseUrl + item, url: this.baseUrl + item };
              } else {
                  item = { name: item, url: item };
              }
              item = { name: item, url: item };
            }
            return item;
          });
@@ -116,13 +112,13 @@
  methods: {
    // 删除图片
    handleRemove(file, fileList) {
      const findex = this.fileList.indexOf(file.name);
      const findex = this.fileList.map(f => f.name).indexOf(file.name);
      this.fileList.splice(findex, 1);
      this.$emit("input", this.listToString(this.fileList));
    },
    // 上传成功回调
    handleUploadSuccess(res) {
      this.fileList.push({ name: res.data.fileName, url: res.data.fileName });
      this.fileList.push({ name: res.data.fileName, url: res.data.url });
      this.$emit("input", this.listToString(this.fileList));
      this.loading.close();
    },