From c0ec9e0e88997247e45f2eaf4f9dab6d8eb4db50 Mon Sep 17 00:00:00 2001 From: QihuAI Design Date: Tue, 14 Jul 2026 22:21:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20ChatPage=20loadMessages=20=E4=B8=AD=20ma?= =?UTF-8?q?pped.forEach=20=E9=97=AD=E5=8C=85=E9=94=99=E8=AF=AF=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E9=A1=B5=E9=9D=A2=E7=99=BD=E5=B1=8F=EF=BC=9B=E7=A7=BB?= =?UTF-8?q?=E8=87=B3=20async=20=E5=86=85=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/front/ChatPage.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/src/pages/front/ChatPage.tsx b/frontend/src/pages/front/ChatPage.tsx index 41f9f49..b2a8da2 100644 --- a/frontend/src/pages/front/ChatPage.tsx +++ b/frontend/src/pages/front/ChatPage.tsx @@ -557,6 +557,12 @@ const ChatPage: React.FC = () => { createdAt: m.createdAt || m.created_at || new Date().toISOString(), })); setMessages(mapped); + // 页面刷新时若仍有「⏳」占位的媒体消息,继续轮询后端回写结果 + mapped.forEach((m) => { + if (m.role === 'assistant' && typeof m.content === 'string' && m.content.startsWith('⏳')) { + startMediaPolling(id, m.id); + } + }); } catch (err) { console.error('加载消息失败', err); setMessages([]); @@ -565,13 +571,6 @@ const ChatPage: React.FC = () => { } }; loadMessages(); - - // 页面刷新时若仍有「⏳」占位的媒体消息,继续轮询后端回写结果 - mapped.forEach((m) => { - if (m.role === 'assistant' && typeof m.content === 'string' && m.content.startsWith('⏳')) { - startMediaPolling(id, m.id); - } - }); }, [id]); // 媒体(图像/视频)异步生成轮询:后端先返回「⏳」占位,前端定时拉取该消息最新内容并回写