| | |
| | | * @param {string} name 下载保存的文件名(可选) |
| | | */ |
| | | export function downloadFileByUrl(url, name) { |
| | | console.log("22222222222222222222", url); |
| | | if (!url) return; |
| | | // 处理相对路径 |
| | | const fullUrl = getFullUrl(url); |
| | | console.log("fullUrl fullUrl", fullUrl); |
| | | console.log("下载文件地址", fullUrl); |
| | | const a = document.createElement("a"); |
| | | a.href = fullUrl; |
| | | if (name) { |
| | |
| | | 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 ? userInfo.allocateIp +'/images/' : apiConfig.showImgUrl; |
| | | return userInfo.allocateIp ? 'http://'+userInfo.allocateIp +':11222/images/' : apiConfig.showImgUrl; |
| | | } |