const BASE_URL = "http://192.168.1.199:18877" //基础路径
function getFileAccessHttpUrl (fileUrl, prefix = 'http') {
let result = fileUrl || '';
if (result.indexOf('../') !== -1 || result.indexOf('/..') !== -1) {
return result;
}
try {
if (fileUrl && fileUrl.length > 0 && !fileUrl.startsWith(prefix)) {
//判断是否是数组格式
let isArray = fileUrl.indexOf('[') != -1;
if (!isArray) {
let prefix = `${BASE_URL}\/hxzyy/sys/common/static/`; //拼接照片路径 根据实际情况
// 判断是否已包含前缀http://192.168.1.199:18877/hxzyy/sys/common/static/CutImage/dou_1696822017257.png
if (!fileUrl.startsWith(prefix)) {
result = `${prefix}${fileUrl}`;
}
}
}
} catch (err) {
}
return result;
}
export const getFileImgHttpUrl = getFileAccessHttpUrl
前端自己处理后端返回的照片
最新推荐文章于 2024-07-12 09:36:48 发布