hejianhao
2026-01-28 5b2e4736b502f4c453c7304a1ad8f7459f1442db
fix: 修正图片上传和显示路径并添加本地存储状态保持

- 将图片上传接口从 `/open/file/upload` 改为 `/work-presentation/upload`
- 统一图片显示路径,添加 `/project/download/` 前缀
- 添加上传失败的错误处理
- 使用 localStorage 保持首页标签页的激活状态
- 修正编辑时图片路径的拼接逻辑
3个文件已修改
35 ■■■■■ 已修改文件
screen/src/view/home/index.vue 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
screen/src/view/workList/detail.vue 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
screen/src/view/workList/index.vue 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
screen/src/view/home/index.vue
@@ -602,7 +602,7 @@
              >
                <el-carousel-item v-for="item in workListData" :key="item.id">
                  <div @click="toWorkDetail(item)" class="cursor-pointer">
                    <img :src="item.img.split(',')[0]" class="w100 h--290" />
                    <img :src="VUE_APP_IMAGE_BASE_URL + item.img.split(',')[0]" class="w100 h--290" />
                    <div
                      class="fs--18 lh--24 SHSBold py--10 pl--20 pr--14 c-fff"
                    >
@@ -798,7 +798,7 @@
      searchTabs: ["本周", "本月", "本季度", "本年"],
      activeTabs: "本周",
      workListData: [],
      VUE_APP_IMAGE_BASE_URL: process.env.VUE_APP_IMAGE_BASE_URL,
      VUE_APP_IMAGE_BASE_URL: process.env.VUE_APP_IMAGE_BASE_URL + "/project/download/",
      projectList: [],
      tooltipVisible: false,
      tooltipPos: { left: 0, top: 0 },
@@ -824,6 +824,9 @@
    },
  },
  created() {
    if (localStorage.getItem("activeTab")) {
      this.activeTab = Number(localStorage.getItem("activeTab"));
    }
    this.mapPromise = AMapLoader.load({
      key: "232929db1cb31f26d42b3645a7456154",
      version: "2.0",
@@ -844,6 +847,7 @@
    });
  },
  beforeDestroy() {
    localStorage.setItem("activeTab", this.activeTab);
    this.stopAutoScroll();
  },
  methods: {
screen/src/view/workList/detail.vue
@@ -35,8 +35,7 @@
          <img
            v-for="(item, index) in detailData.img.split(',')"
            :key="index"
            style="width: 100%; height: 100%"
            :src="item"
            :src="VUE_APP_IMAGE_BASE_URL + item"
          />
        </div>
      </div>
@@ -54,6 +53,7 @@
  data() {
    return {
      detailData: {},
      VUE_APP_IMAGE_BASE_URL: process.env.VUE_APP_IMAGE_BASE_URL + '/project/download/'
    };
  },
  computed: {},
screen/src/view/workList/index.vue
@@ -279,7 +279,7 @@
          <div class="SHSR fs--16 lh--16 mb--17 color1">工作图片:</div>
          <div class="">
            <el-upload
              :action="VUE_APP_BASE_URL + '/open/file/upload'"
              :action="VUE_APP_BASE_URL + '/work-presentation/upload'"
              :headers="uploadHeaders"
              :before-upload="beforeUpload"
              :limit="5"
@@ -437,7 +437,9 @@
        ...this.formData,
        clientId: localStorage.getItem("clientId"),
      };
      obj.img = this.fileList.map((item) => item.url).join(",");
      obj.img = this.fileList
        .map((item) => item.url.substring(item.url.lastIndexOf("/") + 1))
        .join(",");
      let api = obj.id ? updateWorkPresentation : addWorkPresentation;
      api(obj).then((res) => {
        this.closeForm();
@@ -464,10 +466,17 @@
    },
    handleSuccess(response, file, fileList) {
      this.fileList.push({
        url: process.env.VUE_APP_IMAGE_BASE_URL + response.data,
      });
      this.$message.success("上传成功");
      if (response.code == 200) {
        this.fileList.push({
          url:
            process.env.VUE_APP_IMAGE_BASE_URL +
            "/project/download/" +
            response.data.split(".")[0],
        });
        this.$message.success("上传成功");
      } else {
        this.$message.error(response.msg);
      }
    },
    beforeUpload(file) {
@@ -485,7 +494,7 @@
      this.formData = { ...row };
      this.fileList = row.img.split(",").map((item) => {
        return {
          url: item,
          url: process.env.VUE_APP_IMAGE_BASE_URL + "/project/download/" + item,
        };
      });
      this.formVisible = true;