From 7dea456fda8d5486bb3309d51df9d32a5d183a08 Mon Sep 17 00:00:00 2001 From: iven Date: Thu, 16 Apr 2026 02:07:39 +0800 Subject: [PATCH] =?UTF-8?q?chore(settings):=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1=E5=92=8C=E7=A7=AF=E5=88=86=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=20=E2=80=94=20=E4=B8=8E=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E8=AE=A1=E8=B4=B9=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UsageStats 和 Credits 功能已被 PricingPage (订阅与计费) 覆盖, 移除冗余页面简化设置导航。 --- desktop/src/components/Settings/Credits.tsx | 53 ------ .../components/Settings/SettingsLayout.tsx | 10 - .../src/components/Settings/UsageStats.tsx | 177 ------------------ 3 files changed, 240 deletions(-) delete mode 100644 desktop/src/components/Settings/Credits.tsx delete mode 100644 desktop/src/components/Settings/UsageStats.tsx diff --git a/desktop/src/components/Settings/Credits.tsx b/desktop/src/components/Settings/Credits.tsx deleted file mode 100644 index 57ac6e4..0000000 --- a/desktop/src/components/Settings/Credits.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { useState } from 'react'; - -export function Credits() { - const [filter, setFilter] = useState<'all' | 'consume' | 'earn'>('all'); - - return ( -
-
-

积分

-
- - -
-
- -
-
总积分
-
--
-
积分系统开发中
-
- -
- - - -
- -
-
暂无积分记录
-
连接后端服务后即可查看积分使用记录
-
-
- ); -} diff --git a/desktop/src/components/Settings/SettingsLayout.tsx b/desktop/src/components/Settings/SettingsLayout.tsx index 07c31c1..25dfed1 100644 --- a/desktop/src/components/Settings/SettingsLayout.tsx +++ b/desktop/src/components/Settings/SettingsLayout.tsx @@ -2,14 +2,12 @@ import { useState } from 'react'; import { useSecurityStore } from '../../store/securityStore'; import { Settings as SettingsIcon, - BarChart3, Puzzle, MessageSquare, FolderOpen, Shield, Info, ArrowLeft, - Coins, Cpu, Zap, HelpCircle, @@ -24,7 +22,6 @@ import { } from 'lucide-react'; import { silentErrorHandler } from '../../lib/error-utils'; import { General } from './General'; -import { UsageStats } from './UsageStats'; import { ModelsAPI } from './ModelsAPI'; import { MCPServices } from './MCPServices'; import { Skills } from './Skills'; @@ -32,7 +29,6 @@ import { IMChannels } from './IMChannels'; import { Workspace } from './Workspace'; import { Privacy } from './Privacy'; import { About } from './About'; -import { Credits } from './Credits'; import { AuditLogsPanel } from '../AuditLogsPanel'; import { SecurityStatus } from '../SecurityStatus'; import { SecurityLayersPanel } from '../SecurityLayersPanel'; @@ -51,8 +47,6 @@ interface SettingsLayoutProps { type SettingsPage = | 'general' - | 'usage' - | 'credits' | 'models' | 'mcp' | 'skills' @@ -74,8 +68,6 @@ type SettingsPage = const menuItems: { id: SettingsPage; label: string; icon: React.ReactNode; group?: 'advanced' }[] = [ // --- Core settings --- { id: 'general', label: '通用', icon: }, - { id: 'usage', label: '用量统计', icon: }, - { id: 'credits', label: '积分详情', icon: }, { id: 'models', label: '模型与 API', icon: }, { id: 'mcp', label: 'MCP 服务', icon: }, { id: 'im', label: 'IM 频道', icon: }, @@ -105,8 +97,6 @@ export function SettingsLayout({ onBack }: SettingsLayoutProps) { const renderPage = () => { switch (activePage) { case 'general': return ; - case 'usage': return ; - case 'credits': return ; case 'models': return ; case 'mcp': return ; case 'skills': return ; diff --git a/desktop/src/components/Settings/UsageStats.tsx b/desktop/src/components/Settings/UsageStats.tsx deleted file mode 100644 index 55f51ac..0000000 --- a/desktop/src/components/Settings/UsageStats.tsx +++ /dev/null @@ -1,177 +0,0 @@ -import { useEffect, useState } from 'react'; -import { useAgentStore } from '../../store/agentStore'; -import { BarChart3, TrendingUp, Clock, Zap } from 'lucide-react'; - -export function UsageStats() { - const usageStats = useAgentStore((s) => s.usageStats); - const loadUsageStats = useAgentStore((s) => s.loadUsageStats); - const [timeRange, setTimeRange] = useState<'7d' | '30d' | 'all'>('7d'); - - useEffect(() => { - loadUsageStats(); - }, [loadUsageStats]); - - const stats = usageStats || { totalSessions: 0, totalMessages: 0, totalTokens: 0, byModel: {} }; - const models = Object.entries(stats.byModel || {}); - - const formatTokens = (n: number) => { - if (n >= 1_000_000) return `~${(n / 1_000_000).toFixed(1)} M`; - if (n >= 1_000) return `~${(n / 1_000).toFixed(1)} k`; - return `${n}`; - }; - - // 计算总输入和输出 Token - const totalInputTokens = models.reduce((sum, [_, data]) => sum + data.inputTokens, 0); - const totalOutputTokens = models.reduce((sum, [_, data]) => sum + data.outputTokens, 0); - - return ( -
-
-

用量统计

-
-
- {(['7d', '30d', 'all'] as const).map((range) => ( - - ))} -
- -
-
-
本设备所有已保存对话的使用统计。
- - {/* 主要统计卡片 */} -
- - - - -
- - {/* 总 Token 使用量概览 */} -
-

Token 使用概览

- {stats.totalTokens === 0 ? ( -

Token 用量将在后续版本中支持

- ) : ( -
-
-
- 输入 - 输出 -
-
-
-
-
-
-
-
{formatTokens(stats.totalTokens)}
-
总计
-
-
- )} -
- - {/* 按模型分组 */} -

按模型

-
- {models.length === 0 ? ( -
-
- -
-

暂无使用数据

-

开始对话后将自动记录用量统计

-
- ) : ( - models.map(([model, data]) => { - const total = data.inputTokens + data.outputTokens; - const inputPct = (data.inputTokens / Math.max(total, 1)) * 100; - const outputPct = (data.outputTokens / Math.max(total, 1)) * 100; - - return ( -
-
- {model} - {data.messages} 条消息 -
-
-
-
-
-
- 输入: {formatTokens(data.inputTokens)} - 输出: {formatTokens(data.outputTokens)} - 总计: {formatTokens(total)} -
-
- ); - }) - )} -
-
- ); -} - -function StatCard({ - icon: Icon, - label, - value, - color, -}: { - icon: typeof BarChart3; - label: string; - value: string | number; - color: string; -}) { - return ( -
-
- - {label} -
-
{value}
-
- ); -}