董国庆
2025-12-17 10638dc89f1cd2a20c4035383a66192da5dfbccd
culture/src/utils/utils.js
@@ -25,8 +25,6 @@
  axios.post(uploadUrl, formData, { headers: uploadHeaders })
    .then(res => {
      console.log('qweqweqweqw/////',res);
      try {
        onSuccess(res.data);
      } catch (e) {
@@ -41,13 +39,11 @@
      }
    });
};
export function getFullUrl(url) {
  if (!url) return '';
  if (!url) return "";
  if (/^https?:\/\//.test(url)) return url;
  return apiConfig.showImgUrl + url;
  return getAllocateIp() + url;
}
/**
 * 通用文件下载方法
 * @param {string} url 文件的下载地址(支持相对和绝对路径)
@@ -58,7 +54,6 @@
  if (!url) return;
  // 处理相对路径
  const fullUrl = getFullUrl(url);
  console.log('fullUrl fullUrl',fullUrl)
  const a = document.createElement('a');
  a.href = fullUrl;
  if (name) {
@@ -81,3 +76,19 @@
  const fullUrl = getFullUrl(url);
  window.open(fullUrl, '_blank');
}
/**
 * 判断文件是否为图片
 * @param {string} url 文件URL
 * @returns {boolean} 是否为图片文件
 */
export function isImageFile(url) {
  if (!url) return false;
  const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp', '.svg'];
  const lowerUrl = url.toLowerCase();
  return imageExtensions.some(ext => lowerUrl.includes(ext));
}
export function getAllocateIp() {
  const userInfo = JSON.parse(sessionStorage.getItem("userInfo") || "{}");
  return userInfo.allocateIp ? 'http://'+userInfo.allocateIp +':11222/images/' : apiConfig.showImgUrl;
}