refactor(web): 优化 IOD 相关组件和 hooks

- 修改 IodRelevant 组件,根据搜索状态动态显示文本
- 更新 useMessage hook,添加调试断点
- 重构 iod.ts 中的 IoDSources 处理逻辑
This commit is contained in:
zhaoweijie 2025-08-24 12:44:02 +08:00
parent ecb90d9035
commit cb6c3c225b
3 changed files with 14 additions and 8 deletions

View File

@ -228,15 +228,21 @@ export const PlaygroundIodRelevant: React.FC<Props> = ({ className }) => {
return iodSearch && messages.length > 0 && !iodLoading return iodSearch && messages.length > 0 && !iodLoading
}, [iodSearch, messages, iodLoading]) }, [iodSearch, messages, iodLoading])
const data = useMemo(() => { const data = useMemo(() => {
const currentMessage = messages?.find( const currentMessage = messages?.find(
(message) => message.id === currentMessageId (message) => message.id === currentMessageId
) )
const text = (iodSearch && iodLoading) ? '正' : '已'
const text2 = (iodSearch && iodLoading) ? '进行' : '完成'
const text3 = (iodSearch && iodLoading) ? '……' : ''
return [ return [
{ {
title: ( title: (
<p className="font-extrabold"> <p className="font-extrabold">
{text}
<span className="text-[#f00000]"> <span className="text-[#f00000]">
<CountUp end={29} duration={2.5} separator="," /> <CountUp end={29} duration={2.5} separator="," />
</span> </span>
@ -250,7 +256,7 @@ export const PlaygroundIodRelevant: React.FC<Props> = ({ className }) => {
<CountUp decimals={1} end={53.7} duration={2.5} separator="," /> <CountUp decimals={1} end={53.7} duration={2.5} separator="," />
</span> </span>
{text2}{text3}
</p> </p>
), ),
description: showSearchData ? ( description: showSearchData ? (
@ -274,7 +280,7 @@ export const PlaygroundIodRelevant: React.FC<Props> = ({ className }) => {
{ {
title: ( title: (
<p className="font-extrabold"> <p className="font-extrabold">
{text}
<span className="text-[#f00000]"> <span className="text-[#f00000]">
<CountUp end={138} duration={2.5} separator="," /> <CountUp end={138} duration={2.5} separator="," />
@ -284,7 +290,7 @@ export const PlaygroundIodRelevant: React.FC<Props> = ({ className }) => {
<CountUp end={18.3} decimals={1} duration={2.5} separator="," /> <CountUp end={18.3} decimals={1} duration={2.5} separator="," />
</span> </span>
{text2}{text3}
</p> </p>
), ),
description: showSearchData ? ( description: showSearchData ? (
@ -308,7 +314,7 @@ export const PlaygroundIodRelevant: React.FC<Props> = ({ className }) => {
{ {
title: ( title: (
<p className="font-extrabold"> <p className="font-extrabold">
{text}
<span className="text-[#f00000]"> <span className="text-[#f00000]">
<CountUp end={763} duration={2.5} separator="," /> <CountUp end={763} duration={2.5} separator="," />
</span> </span>
@ -322,7 +328,7 @@ export const PlaygroundIodRelevant: React.FC<Props> = ({ className }) => {
{" "} {" "}
<CountUp end={2} duration={2.5} separator="," /> <CountUp end={2} duration={2.5} separator="," />
</span> </span>
{text2}{text3}
</p> </p>
), ),
description: showSearchData ? ( description: showSearchData ? (

View File

@ -507,7 +507,7 @@ export const useMessage = () => {
content: fullText content: fullText
} }
]) ])
debugger
await saveMessageOnSuccess({ await saveMessageOnSuccess({
historyId, historyId,
setHistoryId, setHistoryId,

View File

@ -271,7 +271,7 @@ export const updateDialog = async function (
traceId: r?.traceId traceId: r?.traceId
})) ?? [] })) ?? []
updateBody.IoDSources = updateBody.IoDSources =
botMessage.iodSources?.map((r) => ({ Object.values( botMessage.iodSources as AllIodRegistryEntry).flatMap(iod => iod.data)?.map((r) => ({
id: r.doId, id: r.doId,
tokenCount: tokenCount:
r.content || r.description r.content || r.description