fix: 改进聊天对话中图片下载功能,确保使用原图URL
- 增强原图URL解析逻辑,支持更多S3 URL格式 - 确保下载时始终使用原图URL而不是缩略图 - 改进兜底策略,更好地处理各种URL格式
This commit is contained in:
parent
0d33ca8d85
commit
d1476074e5
@ -105,8 +105,24 @@ export function ImagePreview({
|
||||
} else if (src.includes("openai-thumb-")) {
|
||||
originalUrl = src.replace("openai-thumb-", "openai-orig-");
|
||||
console.log("[ImagePreview] Inferred original URL from openai-thumb filename");
|
||||
} else if (src.includes("/thumb/") || src.includes("-thumb")) {
|
||||
// 尝试从S3 URL中推断原图URL(常见格式:xxx-thumb.jpg -> xxx.jpg 或 xxx/thumb/xxx -> xxx/xxx)
|
||||
originalUrl = src.replace(/-thumb\./g, ".").replace(/\/thumb\//g, "/");
|
||||
console.log("[ImagePreview] Inferred original URL from S3 path pattern");
|
||||
} else {
|
||||
console.log("[ImagePreview] ⚠️ Could not parse original URL, using thumbnail as fallback");
|
||||
// 如果无法推断,且src看起来已经是完整的URL(不是缩略图),直接使用src作为原图
|
||||
// 否则记录警告
|
||||
if (src.startsWith("http://") || src.startsWith("https://")) {
|
||||
// 如果src已经是完整URL且不包含thumb标识,可能是原图
|
||||
if (!src.includes("thumb") && !src.includes("thumbnail")) {
|
||||
originalUrl = src;
|
||||
console.log("[ImagePreview] Using src as original URL (no thumb identifier found)");
|
||||
} else {
|
||||
console.log("[ImagePreview] ⚠️ Could not parse original URL, using thumbnail as fallback");
|
||||
}
|
||||
} else {
|
||||
console.log("[ImagePreview] ⚠️ Could not parse original URL, using thumbnail as fallback");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user