From f9763778fab86f8265cc86ac6db7ce337e57994f Mon Sep 17 00:00:00 2001 From: zhaoweijie Date: Sun, 24 Aug 2025 13:04:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor(components):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E7=A2=98=E6=90=9C=E7=B4=A2=E7=9B=B8=E5=85=B3=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 优化 IodRelevant 组件中的加载状态和计数器动画 - 重构 PlaygroundIod 组件,使用新的 PlaygroundIodProvider 组件 - 改进 Context 提供的数据结构,使用更准确的命名 --- .../Common/Playground/IodRelevant.tsx | 25 +++++++++------- .../Option/Playground/PlaygroundIod.tsx | 29 ++++++++++++++----- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/components/Common/Playground/IodRelevant.tsx b/src/components/Common/Playground/IodRelevant.tsx index 237ab36..5b979b6 100644 --- a/src/components/Common/Playground/IodRelevant.tsx +++ b/src/components/Common/Playground/IodRelevant.tsx @@ -235,25 +235,28 @@ export const PlaygroundIodRelevant: React.FC = ({ className }) => { (message) => message.id === currentMessageId ) - const text = (iodSearch && iodLoading) ? '正' : '已' - const text2 = (iodSearch && iodLoading) ? '进行' : '完成' - const text3 = (iodSearch && iodLoading) ? '……' : '' + const loading = (iodSearch && iodLoading) + const text = loading ? '正' : '已' + const text2 = loading ? '进行' : '完成' + const text3 = loading ? '……' : '' + const duration = loading ? 2.5 : 0 + return [ { title: (

{text}在 - 个 + 国家和省部级科学数据中心、 {" "} - 所 + 高等院校的 - + 万个 科学数据集中{text2}搜索{text3} @@ -282,12 +285,12 @@ export const PlaygroundIodRelevant: React.FC = ({ className }) => {

{text}在 - + 万篇 学术论文、 - + 万个 数据项目中{text2}搜索{text3} @@ -316,17 +319,17 @@ export const PlaygroundIodRelevant: React.FC = ({ className }) => {

{text}在 - 家 + 高等院校和科研机构、 {" "} - 万 + 家科技型企业、 {" "} - 万 + 科技人才中{text2}搜索{text3}

diff --git a/src/components/Option/Playground/PlaygroundIod.tsx b/src/components/Option/Playground/PlaygroundIod.tsx index 1d041c4..e6ab985 100644 --- a/src/components/Option/Playground/PlaygroundIod.tsx +++ b/src/components/Option/Playground/PlaygroundIod.tsx @@ -19,7 +19,7 @@ interface IodPlaygroundContextType { setDetailHeader: React.Dispatch> detailMain: React.ReactNode setDetailMain: React.Dispatch> - currentMessage: Message | null + currentIodMessage: Message | null } // 创建 Context @@ -38,7 +38,9 @@ export const useIodPlaygroundContext = () => { return context } -export const PlaygroundIod = () => { +const PlaygroundIodProvider: React.FC<{ children: React.ReactNode }> = ({ + children +}) => { const { messages, iodLoading, currentMessageId, iodSearch } = useMessageOption() @@ -46,7 +48,7 @@ export const PlaygroundIod = () => { const [detailHeader, setDetailHeader] = useState(<>) const [detailMain, setDetailMain] = useState(<>) - const currentMessage = useMemo(() => { + const currentIodMessage = useMemo(() => { if (iodLoading) { return null } @@ -73,7 +75,7 @@ export const PlaygroundIod = () => { return ( { detailHeader, setDetailHeader }}> -
- -
+ {children}
) } @@ -111,7 +111,9 @@ const PlaygroundContent = () => { className="h-full grid grid-rows-12 gap-3">
@@ -151,3 +153,14 @@ const PlaygroundContent = () => { ) } + + +export const PlaygroundIod = () => { + return ( +
+ + + +
+ ) +}