From cb6c3c225b5beb3a9b4380ac6d943ad8e8d087cb Mon Sep 17 00:00:00 2001 From: zhaoweijie Date: Sun, 24 Aug 2025 12:44:02 +0800 Subject: [PATCH] =?UTF-8?q?refactor(web):=20=E4=BC=98=E5=8C=96=20IOD=20?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=BB=84=E4=BB=B6=E5=92=8C=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 IodRelevant 组件,根据搜索状态动态显示文本 - 更新 useMessage hook,添加调试断点 - 重构 iod.ts 中的 IoDSources 处理逻辑 --- .../Common/Playground/IodRelevant.tsx | 18 ++++++++++++------ src/hooks/useMessage.tsx | 2 +- src/web/iod.ts | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/Common/Playground/IodRelevant.tsx b/src/components/Common/Playground/IodRelevant.tsx index 78c018a..237ab36 100644 --- a/src/components/Common/Playground/IodRelevant.tsx +++ b/src/components/Common/Playground/IodRelevant.tsx @@ -228,15 +228,21 @@ export const PlaygroundIodRelevant: React.FC = ({ className }) => { return iodSearch && messages.length > 0 && !iodLoading }, [iodSearch, messages, iodLoading]) + + const data = useMemo(() => { const currentMessage = messages?.find( (message) => message.id === currentMessageId ) + + const text = (iodSearch && iodLoading) ? '正' : '已' + const text2 = (iodSearch && iodLoading) ? '进行' : '完成' + const text3 = (iodSearch && iodLoading) ? '……' : '' return [ { title: (

- 已在 + {text}在 @@ -250,7 +256,7 @@ export const PlaygroundIodRelevant: React.FC = ({ className }) => { 万个 - 科学数据集中进行搜索 + 科学数据集中{text2}搜索{text3}

), description: showSearchData ? ( @@ -274,7 +280,7 @@ export const PlaygroundIodRelevant: React.FC = ({ className }) => { { title: (

- 已在 + {text}在 万篇 @@ -284,7 +290,7 @@ export const PlaygroundIodRelevant: React.FC = ({ className }) => { 万个 - 数据项目中进行搜索 + 数据项目中{text2}搜索{text3}

), description: showSearchData ? ( @@ -308,7 +314,7 @@ export const PlaygroundIodRelevant: React.FC = ({ className }) => { { title: (

- 已在 + {text}在 @@ -322,7 +328,7 @@ export const PlaygroundIodRelevant: React.FC = ({ className }) => { {" "} 万 - 科技人才中进行搜索 + 科技人才中{text2}搜索{text3}

), description: showSearchData ? ( diff --git a/src/hooks/useMessage.tsx b/src/hooks/useMessage.tsx index 1b528b7..088f6b7 100644 --- a/src/hooks/useMessage.tsx +++ b/src/hooks/useMessage.tsx @@ -507,7 +507,7 @@ export const useMessage = () => { content: fullText } ]) - + debugger await saveMessageOnSuccess({ historyId, setHistoryId, diff --git a/src/web/iod.ts b/src/web/iod.ts index a0fec91..114edf3 100644 --- a/src/web/iod.ts +++ b/src/web/iod.ts @@ -271,7 +271,7 @@ export const updateDialog = async function ( traceId: r?.traceId })) ?? [] updateBody.IoDSources = - botMessage.iodSources?.map((r) => ({ + Object.values( botMessage.iodSources as AllIodRegistryEntry).flatMap(iod => iod.data)?.map((r) => ({ id: r.doId, tokenCount: r.content || r.description