From 61e6cc9e4201dd0cb273283aebf7e0f72308b774 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Tue, 30 Dec 2025 18:52:25 +0800 Subject: [PATCH] feat(web): update user statement page UI --- web/src/routes/routes.json | 4 +- .../components/EndUserProfile.tsx | 1 - .../components/NodeStatistics copy.tsx | 88 ------------------- .../components/PageHeader.tsx | 12 ++- .../pages/StatementDetail.tsx | 53 ++++++++--- 5 files changed, 51 insertions(+), 107 deletions(-) delete mode 100644 web/src/views/UserMemoryDetail/components/NodeStatistics copy.tsx diff --git a/web/src/routes/routes.json b/web/src/routes/routes.json index 9d3e9cb8..73431f67 100644 --- a/web/src/routes/routes.json +++ b/web/src/routes/routes.json @@ -32,7 +32,6 @@ { "path": "/api-key", "element": "ApiKeyManagement" }, { "path": "/emotion-engine/:id", "element": "EmotionEngine" }, { "path": "/reflection-engine/:id", "element": "SelfReflectionEngine" }, - { "path": "/statement/:id", "element": "StatementDetail" }, { "path": "/no-permission", "element": "NoPermission" }, { "path": "/*", "element": "NotFound" } ] @@ -42,7 +41,8 @@ "children": [ { "path": "/application/config/:id", "element": "ApplicationConfig" }, { "path": "/conversation/:token", "element": "Conversation" }, - { "path": "/user-memory/neo4j/:id", "element": "Neo4jUserMemoryDetail" } + { "path": "/user-memory/neo4j/:id", "element": "Neo4jUserMemoryDetail" }, + { "path": "/statement/:id", "element": "StatementDetail" } ] }, { diff --git a/web/src/views/UserMemoryDetail/components/EndUserProfile.tsx b/web/src/views/UserMemoryDetail/components/EndUserProfile.tsx index ac98d9aa..0e2ff828 100644 --- a/web/src/views/UserMemoryDetail/components/EndUserProfile.tsx +++ b/web/src/views/UserMemoryDetail/components/EndUserProfile.tsx @@ -27,7 +27,6 @@ const EndUserProfile = forwardRef(({ onD getData() }, [id]) - // 记忆洞察 const getData = () => { if (!id) return setLoading(true) diff --git a/web/src/views/UserMemoryDetail/components/NodeStatistics copy.tsx b/web/src/views/UserMemoryDetail/components/NodeStatistics copy.tsx deleted file mode 100644 index f5f7df34..00000000 --- a/web/src/views/UserMemoryDetail/components/NodeStatistics copy.tsx +++ /dev/null @@ -1,88 +0,0 @@ -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 NodeStatisticsItem[] - setData(response) - // 计算count总计 - const totalCount = response.reduce((sum, item) => sum + (item.count || 0), 0) - setTotal(totalCount) - setLoading(false) - }) - .finally(() => { - setLoading(false) - }) - } - const handleViewDetail = (type: string) => { - switch (type) { - case 'EMOTIONAL_MEMORY': - navigate(`/statement/${id}`) - break - } - } - return ( - {t('userMemory.nodeStatistics')}
{t('userMemory.total')}: {total}
} - headerType="borderless" - > - {loading - ? - : data && data.length > 0 - ?
- {data.map(vo => ( -
handleViewDetail(vo.type)} - > -
-
{t(`userMemory.${vo.type}`)}
- {vo.type === 'EMOTIONAL_MEMORY' &&
} -
- -
- {vo.count ?? 0} -
- {vo.percentage ?? 0}% -
-
-
- ))} -
- : - } -
- ) -} -export default NodeStatistics \ No newline at end of file diff --git a/web/src/views/UserMemoryDetail/components/PageHeader.tsx b/web/src/views/UserMemoryDetail/components/PageHeader.tsx index a1a0a2ea..dda60e7e 100644 --- a/web/src/views/UserMemoryDetail/components/PageHeader.tsx +++ b/web/src/views/UserMemoryDetail/components/PageHeader.tsx @@ -8,17 +8,23 @@ const { Header } = Layout; interface ConfigHeaderProps { name?: string; - operation: ReactNode + operation?: ReactNode; + source?: 'detail' | 'statement' } const PageHeader: FC = ({ name, - operation + operation, + source = 'detail' }) => { const { t } = useTranslation(); const navigate = useNavigate(); const goBack = () => { - navigate('/user-memory', { replace: true }) + if (source === 'detail') { + navigate('/user-memory', { replace: true }) + } else { + navigate(-1) + } } return (
diff --git a/web/src/views/UserMemoryDetail/pages/StatementDetail.tsx b/web/src/views/UserMemoryDetail/pages/StatementDetail.tsx index e6ddfd20..744c244d 100644 --- a/web/src/views/UserMemoryDetail/pages/StatementDetail.tsx +++ b/web/src/views/UserMemoryDetail/pages/StatementDetail.tsx @@ -1,26 +1,53 @@ -import { type FC } from 'react' +import { type FC, useEffect, useState } from 'react' +import { useParams } from 'react-router-dom' import { Row, Col, Space } from 'antd'; import WordCloud from '../components/WordCloud' import EmotionTags from '../components/EmotionTags' import Health from '../components/Health' import Suggestions from '../components/Suggestions' +import PageHeader from '../components/PageHeader' +import { + getEndUserProfile, +} from '@/api/memory' const StatementDetail: FC = () => { + const { id } = useParams() + const [name, setName] = useState('') + useEffect(() => { + if (!id) return + getData() + }, [id]) + + const getData = () => { + if (!id) return + getEndUserProfile(id).then((res) => { + const response = res as { other_name: string; id: string; } + setName(response.other_name ?? response.id) + }) + } return ( - - - - - - - - - - - - +
+ +
+ + + + + + + + + + + + +
+
) }