fix(chat): 图片消息优先使用包含 file_id 的本地 URL

- 当服务端返回本地 /api/chat/media/image URL 时,优先使用前端拼的本地 URL(携带 file_id),提高兜底命中率
This commit is contained in:
2977094657
2025-12-30 11:15:44 +08:00
parent 23dd59ed4d
commit 87605c42ef

View File

@@ -3292,7 +3292,14 @@ const normalizeMessage = (msg) => {
].filter(Boolean)
return `${mediaBase}/api/chat/media/image?${parts.join('&')}`
})()
const normalizedImageUrl = msg.imageUrl || localImageUrl || ''
const normalizedImageUrl = (() => {
const cur = (isUsableMediaUrl(msg.imageUrl) ? normalizeMaybeUrl(msg.imageUrl) : '')
// If backend already returns a local media endpoint, prefer the locally-built URL because it includes file_id.
if (cur && /\/api\/chat\/media\/image\b/i.test(cur) && localImageUrl) {
return localImageUrl
}
return cur || localImageUrl || ''
})()
const normalizedEmojiUrl = msg.emojiUrl || localEmojiUrl
const localVideoThumbUrl = (() => {
if (!msg.videoThumbMd5 && !msg.videoThumbFileId) return ''