From db00d44a71ded1ae2a868c7f2721fbed1fea02df Mon Sep 17 00:00:00 2001 From: kyx236 Date: Thu, 5 Feb 2026 07:51:03 +0800 Subject: [PATCH] feat: Implement initial backend API server with various endpoints and background services, including an error account cleaner. --- backend/cmd/main.go | 2 +- backend/internal/api/error_cleaner.go | 2 +- .../src/components/dashboard/PoolStatus.tsx | 22 +++++++++---------- .../src/components/dashboard/StatsCard.tsx | 10 +++++++++ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/backend/cmd/main.go b/backend/cmd/main.go index fdff0af..afe43a9 100644 --- a/backend/cmd/main.go +++ b/backend/cmd/main.go @@ -508,7 +508,7 @@ func handleS2ATest(w http.ResponseWriter, r *http.Request) { } // 请求 S2A 仪表盘接口 - dashboardURL := config.Global.S2AApiBase + "/api/v1/admin/dashboard" + dashboardURL := config.Global.S2AApiBase + "/api/v1/admin/dashboard/stats" req, err := http.NewRequest("GET", dashboardURL, nil) if err != nil { api.Error(w, http.StatusInternalServerError, "创建请求失败") diff --git a/backend/internal/api/error_cleaner.go b/backend/internal/api/error_cleaner.go index 0bd2704..4732758 100644 --- a/backend/internal/api/error_cleaner.go +++ b/backend/internal/api/error_cleaner.go @@ -75,7 +75,7 @@ func getTotalAccountCount() (int, error) { } client := &http.Client{Timeout: 30 * time.Second} - url := fmt.Sprintf("%s/api/v1/admin/dashboard", config.Global.S2AApiBase) + url := fmt.Sprintf("%s/api/v1/admin/dashboard/stats", config.Global.S2AApiBase) req, err := http.NewRequest("GET", url, nil) if err != nil { diff --git a/frontend/src/components/dashboard/PoolStatus.tsx b/frontend/src/components/dashboard/PoolStatus.tsx index a3d3b66..275c11d 100644 --- a/frontend/src/components/dashboard/PoolStatus.tsx +++ b/frontend/src/components/dashboard/PoolStatus.tsx @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react' -import { Users, CheckCircle, XCircle, AlertTriangle, Zap, Activity, TrendingUp } from 'lucide-react' +import { Users, CheckCircle, XCircle, AlertTriangle, Zap, Activity } from 'lucide-react' import type { DashboardStats } from '../../types' import StatsCard from './StatsCard' @@ -78,17 +78,15 @@ export default function PoolStatus({ stats, loading, error }: PoolStatusProps) { color="slate" loading={loading} /> - {/* RPM 卡片 - 显示当前 RPM 和今日最高 */} -
- - {/* 今日最高 RPM 显示在卡片下方 */} - {maxRpm > 0 && ( -
- - 今日最高: {maxRpm} -
- )} -
+ 0 ? `📈 今日最高: ${maxRpm}` : undefined} + /> ) } + diff --git a/frontend/src/components/dashboard/StatsCard.tsx b/frontend/src/components/dashboard/StatsCard.tsx index 9679dea..fe50c12 100644 --- a/frontend/src/components/dashboard/StatsCard.tsx +++ b/frontend/src/components/dashboard/StatsCard.tsx @@ -10,6 +10,8 @@ interface StatsCardProps { trendValue?: string color?: 'blue' | 'green' | 'yellow' | 'red' | 'slate' loading?: boolean + subtitle?: string + subtitleColor?: string } export default function StatsCard({ @@ -20,6 +22,8 @@ export default function StatsCard({ trendValue, color = 'blue', loading = false, + subtitle, + subtitleColor = 'text-orange-500', }: StatsCardProps) { const colorStyles = { blue: { @@ -80,6 +84,11 @@ export default function StatsCard({ )} + {subtitle && ( +

+ {subtitle} +

+ )} {trend && trendValue && TrendIcon && (
@@ -94,3 +103,4 @@ export default function StatsCard({ ) } +