From 87605c42ef859dc60ba744f01d12cd0a3a828509 Mon Sep 17 00:00:00 2001 From: 2977094657 <2977094657@qq.com> Date: Tue, 30 Dec 2025 11:15:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=E5=9B=BE=E7=89=87=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E4=BC=98=E5=85=88=E4=BD=BF=E7=94=A8=E5=8C=85=E5=90=AB?= =?UTF-8?q?=20file=5Fid=20=E7=9A=84=E6=9C=AC=E5=9C=B0=20URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 当服务端返回本地 /api/chat/media/image URL 时,优先使用前端拼的本地 URL(携带 file_id),提高兜底命中率 --- frontend/pages/chat/[[username]].vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/pages/chat/[[username]].vue b/frontend/pages/chat/[[username]].vue index 6785c96..fd934d7 100644 --- a/frontend/pages/chat/[[username]].vue +++ b/frontend/pages/chat/[[username]].vue @@ -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 ''