From 8dd593e74777f1c87fa2fc7e011adf65e2987ed7 Mon Sep 17 00:00:00 2001 From: thzxx Date: Sat, 27 Jun 2026 22:38:53 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20TokenUsage=20=E5=BA=95=E9=83=A8?= =?UTF-8?q?=E6=B1=87=E6=80=BB=E6=94=B9=E7=94=A8=20MUI=20Table=EF=BC=8C?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E4=B8=8E=E5=80=BC=E8=87=AA=E7=84=B6=E5=88=86?= =?UTF-8?q?=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/trace/TokenUsage.tsx | 42 ++++++++++++++++++----------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/components/trace/TokenUsage.tsx b/src/components/trace/TokenUsage.tsx index 5919e91..840a4b9 100644 --- a/src/components/trace/TokenUsage.tsx +++ b/src/components/trace/TokenUsage.tsx @@ -5,7 +5,7 @@ * 固定在详情面板中部,高度由内容自然决定。 */ -import { Box, Typography, Stack } from '@mui/material'; +import { Box, Typography, Stack, Table, TableBody, TableRow, TableCell } from '@mui/material'; import { Zap } from 'lucide-react'; import { useAgentStore } from '@renderer/stores/agent-store'; import { formatTokens } from '@renderer/lib/formatters'; @@ -46,12 +46,31 @@ export function TokenUsage(): React.JSX.Element { {/* 底部汇总 */} - - 0 ? formatTokens(tokenUsage.totalTokens) : '-'} highlight /> - 0 ? `${usagePercent.toFixed(1)}%` : '-'} - color={usagePercent > 80 ? 'error.main' : usagePercent > 60 ? 'warning.main' : undefined} /> - - + + + + 总计 + + {tokenUsage.totalTokens > 0 ? formatTokens(tokenUsage.totalTokens) : '-'} + + + + 上下文 + 80 ? 'error.main' : usagePercent > 60 ? 'warning.main' : 'text.secondary', + }}> + {tokenUsage.totalTokens > 0 ? `${usagePercent.toFixed(1)}%` : '-'} + + + + 迭代 + + {currentIteration} / {maxIterations} + + + +
); } @@ -65,12 +84,3 @@ function StatCard({ label, value, color }: { label: string; value: string; color ); } - -function SummaryRow({ label, value, highlight, color }: { label: string; value: string; highlight?: boolean; color?: string }) { - return ( - - {label} - {value} - - ); -}