import { type FC, useEffect, useState } from 'react' import clsx from 'clsx' import { useTranslation } from 'react-i18next' import { useParams, useNavigate } from 'react-router-dom' import { Skeleton } from 'antd'; import RbCard from '@/components/RbCard/Card' import Empty from '@/components/Empty'; import { getNodeStatistics, } from '@/api/memory' import type { NodeStatisticsItem } from '../types' const NodeStatistics: FC = () => { const navigate = useNavigate(); const { t } = useTranslation() const { id } = useParams() const [loading, setLoading] = useState(false) const [total, setTotal] = useState(0) const [data, setData] = useState([]) useEffect(() => { if (!id) return getData() }, [id]) // 记忆洞察 const getData = () => { if (!id) return setLoading(true) getNodeStatistics(id).then((res) => { const response = res as { nodes: NodeStatisticsItem[], total: number } setData(response.nodes) setTotal(response.total) setLoading(false) }) .finally(() => { setLoading(false) }) } const handleViewDetail = (type: string) => { switch (type) { case 'Statement': navigate(`/statement/${id}`) break } } return ( {t('userMemory.total')}: {total}} headerType="borderless" headerClassName="rb:text-[18px]! rb:leading-[24px]" bgColor="linear-gradient(180deg,#F1F9FE 0%, #FBFCFF 100%)" height="100%" > {loading ? : data.length > 0 ?
{data.map(vo => (
handleViewDetail(vo.type)} >
{t(`userMemory.${vo.type}`)}
{vo.type === 'Statement' &&
}
{vo.count ?? 0}
{vo.percentage ?? 0}%
))}
: }
) } export default NodeStatistics