/* * @Author: ZhaoYing * @Date: 2026-02-03 17:53:44 * @Last Modified by: ZhaoYing * @Last Modified time: 2026-02-03 17:54:33 */ /** * User Memory Page * Displays list of end users with their memory statistics and configuration */ import { useEffect, useState, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom' import { Row, Col, List, Skeleton } from 'antd'; import Empty from '@/components/Empty' import type { Data } from './types' import { getUserMemoryList } from '@/api/memory'; import { useUser } from '@/store/user' import RbCard from '@/components/RbCard/Card' import SearchInput from '@/components/SearchInput'; export default function UserMemory() { const { t } = useTranslation(); const navigate = useNavigate() const { storageType } = useUser() const [loading, setLoading] = useState(false); const [data, setData] = useState([]); const [search, setSearch] = useState(undefined); /** Fetch user memory list */ useEffect(() => { getData() }, []); /** Get data from API */ const getData = () => { setLoading(true) getUserMemoryList().then((res) => { setData(res as Data[] || []) }) .finally(() => { setLoading(false) }) } /** Navigate to user memory detail */ const handleViewDetail = (id: string | number) => { switch (storageType) { case 'neo4j': navigate(`/user-memory/neo4j/${id}`) break; default: navigate(`/user-memory/${id}`) } } /** Navigate to memory configuration */ const handleViewMemoryConfig = (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); navigate(`/memory`) } /** Filter data by search term */ const filterData = useMemo(() => { if (search && search.trim() !== '') { return data.filter((item) => { const { end_user } = item as Data; const name = end_user?.other_name && end_user?.other_name !== '' ? end_user?.other_name : end_user?.id return name?.includes(search) }) } return data }, [search, data]) return (
setSearch(value)} style={{ width: '100%' }} /> {loading ? : filterData.length > 0 ? ( { const { end_user, memory_num, memory_config } = item as Data; const name = end_user?.other_name && end_user?.other_name !== '' ? end_user?.other_name : end_user?.id return ( {name[0]}
} title={name || '-'} extra={
} className="rb:cursor-pointer" onClick={() => handleViewDetail(end_user.id)} >
{t('userMemory.capacity')}
{memory_num?.total || 0} {t('userMemory.memoryNum')}
{t('userMemory.type')}
{t(`userMemory.${item.type || 'person'}`)}
{t('userMemory.memory_config_name')}
{memory_config?.memory_config_name || '-'}
) }} /> ) : } ); }