zhangwencui
8 天以前 9e1e28591e0de5fa8f36abc144922e7809e60262
图片预览问题
已修改3个文件
57 ■■■■■ 文件已修改
src/pages/equipmentManagement/upkeep/detail.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/equipmentManagement/upkeep/maintain.vue 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/inspectionUpload/index.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/equipmentManagement/upkeep/detail.vue
@@ -199,9 +199,9 @@
    const uploadsIndex = url.indexOf("uploads");
    if (uploadsIndex !== -1) {
      const relativePath = url.substring(uploadsIndex);
      return `${config.baseUrl}/profile/${relativePath}`;
      return `${config.baseUrl}/${relativePath}`;
    }
    return `${config.baseUrl}/profile/${url}`;
    return `${config.baseUrl}/${url}`;
  };
  // 判断是否为图片文件
src/pages/equipmentManagement/upkeep/maintain.vue
@@ -123,8 +123,9 @@
                  :key="index"
                  class="file-item">
              <view class="file-preview-container">
                {{formatFileUrl(file.url)}}
                <image v-if="file.type === 'image' || isImageFile(file)"
                       :src="file.url || file.tempFilePath || file.path || file.downloadUrl"
                       :src="formatFileUrl(file.url || file.tempFilePath || file.path || file.downloadUrl)"
                       class="file-preview"
                       mode="aspectFill" />
                <view v-else-if="file.type === 'video'"
@@ -634,26 +635,26 @@
  };
  // 格式化文件URL
  const formatFileUrl = url => {
    if (!url) return "";
  // const formatFileUrl = url => {
  //   if (!url) return "";
    // 如果已经是完整的URL(http或https开头),直接返回
    if (url.startsWith("http://") || url.startsWith("https://")) {
      return url;
    }
  //   // 如果已经是完整的URL(http或https开头),直接返回
  //   if (url.startsWith("http://") || url.startsWith("https://")) {
  //     return url;
  //   }
    // 如果是本地路径(如 D:\\ruoyi\\prod\\uploads...),需要转换为网络URL
    // 从路径中提取uploads后面的部分
    const uploadsIndex = url.indexOf("uploads");
    if (uploadsIndex !== -1) {
      const relativePath = url.substring(uploadsIndex);
      // 使用baseUrl + /profile/ + 相对路径
      return `http://192.168.1.35:8888/profile/${relativePath}`;
    }
  //   // 如果是本地路径(如 D:\\ruoyi\\prod\\uploads...),需要转换为网络URL
  //   // 从路径中提取uploads后面的部分
  //   const uploadsIndex = url.indexOf("uploads");
  //   if (uploadsIndex !== -1) {
  //     const relativePath = url.substring(uploadsIndex);
  //     // 使用baseUrl + /profile/ + 相对路径
  //     return `http://192.168.1.35:8888/profile/${relativePath}`;
  //   }
    // 其他情况,尝试直接拼接
    return `http://192.168.1.35:8888/profile/${url}`;
  };
  //   // 其他情况,尝试直接拼接
  //   return `http://192.168.1.35:8888/profile/${url}`;
  // };
  // 格式化文件大小
  const formatFileSize = size => {
@@ -920,6 +921,18 @@
        uploadProgress.value = res.progress;
      });
    }
  }; // 格式化文件URL
  const formatFileUrl = url => {
    if (!url) return "";
    if (url.startsWith("http://") || url.startsWith("https://")) {
      return url;
    }
    const uploadsIndex = url.indexOf("uploads");
    if (uploadsIndex !== -1) {
      const relativePath = url.substring(uploadsIndex);
      return `${config.baseUrl}/${relativePath}`;
    }
    return `${config.baseUrl}/${url}`;
  };
  // 上传成功处理
src/pages/inspectionUpload/index.vue
@@ -1599,9 +1599,9 @@
    const uploadsIndex = url.indexOf("uploads");
    if (uploadsIndex !== -1) {
      const relativePath = url.substring(uploadsIndex);
      return `${config.baseUrl}/profile/${relativePath}`;
      return `${config.baseUrl}/${relativePath}`;
    }
    return `${config.baseUrl}/profile/${url}`;
    return `${config.baseUrl}/${url}`;
  };
  // 格式化文件大小
  const formatFileSize = size => {