import React, { useMemo, useState } from "react" import { DataNavigation } from "@/components/Common/DataNavigation.tsx" import { Card, Drawer, Skeleton } from "antd" import { IodRegistryEntry } from "@/types/iod.ts" const defaultData: IodRegistryEntry[] = [ { name: "绿色化工工艺项目", description: "基于生物基原料,采用repeal2.0可降解材料技术,开发新型环保材料。", doId: "CSTR:13552.11.01.61.2021.742" }, { name: "智能农业解决方案", description: "利用物联网技术,实现精准农业管理,提高农作物产量。", doId: "CSTR:14542.11.01.61.2031.528" }, { name: "新能源汽车电池技术", description: "研发高能量密度、长寿命的新型电池材料,推动电动汽车发展。", doId: "CSTR:147842.11.04.91.2031.680" }, { name: "碳捕集与封存技术", description: "开发高效的碳捕集技术,减少工业排放,助力碳中和目标。", doId: "CSTR:14242.19.11.61.2131.428" } ] type ShowCardProps = { loading: boolean record: IodRegistryEntry truncate?: boolean } const ShowCard: React.FC = ({ loading, record, truncate = true }) => ( {loading ? ( ) : (

{record.name}

数字对象标识:{record.doId}

{record.description}

)}
) export const PlaygroundScene = () => { const { messages, iodLoading, currentMessageId, iodSearch } = useMessageOption() const data = useMemo(() => { // 确保loading状态时数据大于3 if (iodLoading) { return defaultData } if (messages.length && iodSearch) { const currentMessage = messages?.find( (message) => message.id === currentMessageId ) return currentMessage?.iodSources.scenario.data ?? [] } return defaultData }, [currentMessageId, messages, iodLoading]) const title = useMemo(() => { return messages.length > 0 ? "推荐场景" : "热点场景" }, [messages]) const [open, setOpen] = useState(false) const showDrawer = () => { if (iodLoading) { return } setOpen(true) } const onClose = () => { setOpen(false) } return (
{/* 数据导航 */} {title}
} onClick={showDrawer} /> {/* 数据列表 */}
{data.slice(0, 3).map((item, index) => { return ( ) })}
{/* 抽屉 */}
{data.map((item, index) => ( ))}
) }