消息列表支持显示图片

This commit is contained in:
liuwei
2025-04-01 17:16:13 +08:00
parent 8fdfc723e8
commit bd4c6dd627
2 changed files with 30 additions and 3 deletions

View File

@@ -341,8 +341,23 @@
// 如果路径为空,返回空字符串
if (!imagePath) return '';
// 提取文件名
const fileName = imagePath.split('\\').pop().split('/').pop();
// 如果已经是完整URL直接返回
if (imagePath.startsWith('http://') || imagePath.startsWith('https://')) {
return imagePath;
}
// 提取文件名和路径
const pathParts = imagePath.split(/[\/\\]/);
const fileName = pathParts[pathParts.length - 1];
// 如果路径包含群ID通常是倒数第二个部分
if (pathParts.length >= 2) {
const groupId = pathParts[pathParts.length - 2];
// 检查是否是群ID格式通常以@chatroom结尾
if (groupId.includes('@chatroom')) {
return `/static/images/${groupId}/${fileName}`;
}
}
// 检查路径中是否包含static/images
if (imagePath.includes('static/images') || imagePath.includes('static\\images')) {
@@ -353,7 +368,7 @@
}
}
// 如果不包含static/images,则直接使用文件名
// 如果以上都不匹配,则直接使用文件名
return `/static/images/${fileName}`;
}
},