diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts index 829def52..4a7a3b54 100644 --- a/web/src/i18n/en.ts +++ b/web/src/i18n/en.ts @@ -131,15 +131,15 @@ export const en = { desc_spaces: 'compared to last week', desc_users: 'New additions this week', desc_running_apps: "Today's success rate", - totalMemoryCapacity: 'Total Stored Memories', + total_memory: 'Total Stored Memories', userMemory: 'User Memory', - knowledgeBaseCount: 'Knowledge Bases', - apiCallCount: 'API Calls', + total_knowledge: 'Knowledge Bases', + total_api_call: 'API Calls', comparedToYesterday: 'compared to yesterday', thisWeek: 'this week', thisDay: 'day on day', failureRate: 'Failure Rate', - application: 'Applications', + total_app: 'Applications', total_num: 'Total Memory Capacity', lastDays: 'last {{days}} days', diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.ts index 4c181adf..7ec1d5df 100644 --- a/web/src/i18n/zh.ts +++ b/web/src/i18n/zh.ts @@ -842,15 +842,15 @@ export const zh = { desc_spaces: '多于上周', desc_users: '本周新增', desc_running_apps: '今日成功率', - totalMemoryCapacity: '总记忆容量', + total_memory: '总记忆容量', userMemory: '用户记忆', - knowledgeBaseCount: '知识库数量', - apiCallCount: 'API调用次数', + total_knowledge: '知识库数量', + total_api_call: 'API调用次数', comparedToYesterday: '与昨天相比', thisWeek: '本周', thisDay: '本日', failureRate: '故障率', - application: '应用数量', + total_app: '应用数量', total_num: '总记忆容量', lastDays: '最近{{days}}天', diff --git a/web/src/views/Home/components/TopCardList.tsx b/web/src/views/Home/components/TopCardList.tsx index 751f232a..25f11a55 100644 --- a/web/src/views/Home/components/TopCardList.tsx +++ b/web/src/views/Home/components/TopCardList.tsx @@ -15,49 +15,22 @@ import { useTranslation } from 'react-i18next' import clsx from 'clsx'; import { Flex } from 'antd'; -import totalMemoryCapacity from '@/assets/images/home/totalMemoryCapacity.svg'; -import userMemory from '@/assets/images/home/userMemory.svg'; -import knowledgeBaseCount from '@/assets/images/home/knowledgeBaseCount.svg'; -import apiCallCount from '@/assets/images/home/apiCallCount.svg'; import type { DashboardData } from '../index' /** Card configuration with styling */ const list = [ { - key: 'totalMemoryCapacity', - icon: totalMemoryCapacity, - // value: '45,678', - // trendValue: '12.5%', - // trend: 'up', - // trendDesc: 'comparedToYesterday', + key: 'total_memory', background: 'rb:bg-[url("@/assets/images/home/totalMemoryCapacity.png")] rb:bg-cover rb:bg-no-repeat', }, { - key: 'application', - icon: userMemory, - // value: '32,145', - // trendValue: '12.5%', - // trend: 'down', - // trendDesc: 'comparedToYesterday', - // background: 'linear-gradient( 180deg, #F1FBF5 0%, #F9FDFF 100%)', + key: 'total_app', }, { - key: 'knowledgeBaseCount', - icon: knowledgeBaseCount, - // value: '13,533', - // trendValue: '15.7%', - // trend: 'up', - // trendDesc: 'thisWeek', - // background: 'linear-gradient( 180deg, #E6F5FE 0%, #FBFDFF 100%)', + key: 'total_knowledge', }, { - key: 'apiCallCount', - icon: apiCallCount, - // value: '856.2k', - // trendValue: '23.1%', - // trend: 'up', - // trendDesc: 'comparedToYesterday', - // background: 'linear-gradient( 180deg, #F8F6F5 0%, #FAFDFF 100%)', + key: 'total_api_call', }, ] /** @@ -75,30 +48,32 @@ const TopCardList: FC<{data?: DashboardData}> = ({ data }) => { className={`rb:rounded-2xl rb:bg-[#FFFFFF] rb:py-4 rb:px-3 ${item.background || ''}`} >
{t(`dashboard.${item.key}`)}
{data?.[item.key as keyof DashboardData] || 0}
= 0, })}> - 0% + {data?.[`${item.key}_change` as keyof DashboardData] && data?.[item.key as keyof DashboardData] > 0 + ? (100 * data?.[`${item.key}_change` as keyof DashboardData] / data?.[item.key as keyof DashboardData]).toFixed(2) + : 0 + }%
= 0, })}>
{t('dashboard.comparedToYesterday')}
diff --git a/web/src/views/Home/index.tsx b/web/src/views/Home/index.tsx index 2844b816..ae2c89fa 100644 --- a/web/src/views/Home/index.tsx +++ b/web/src/views/Home/index.tsx @@ -25,14 +25,18 @@ import ApiLineCard from './components/ApiLineCard' * Dashboard statistics data */ export interface DashboardData { - totalMemoryCapacity?: number; - application?: number; - knowledgeBaseCount?: number; - apiCallCount?: number; + total_memory: number; + total_app: number; + total_knowledge: number; + total_api_call: number; + total_memory_change: number; + total_app_change: number; + total_knowledge_change: number; + total_api_call_change: number; } const Home = () => { - const [dashboardData, setDashboardData] = useState({}); + const [dashboardData, setDashboardData] = useState({} as DashboardData); const [loading, setLoading] = useState({ knowledgeTypeDistribution: true, }); @@ -65,12 +69,7 @@ const Home = () => { } const { storage_type = 'neo4j' } = response || {} const responseData = storage_type === 'neo4j' ? response.neo4j_data : response.rag_data - setDashboardData({ - totalMemoryCapacity: responseData?.total_memory || 0, - application: responseData?.total_app || 0, - knowledgeBaseCount: responseData?.total_knowledge || 0, - apiCallCount: responseData?.total_api_call || 0 - }) + setDashboardData(responseData as DashboardData) }) } /** Fetch knowledge base type distribution */