feat: Implement Max RPM tracking API, Codex API authentication, and a new dashboard pool status component.

This commit is contained in:
2026-02-05 06:30:47 +08:00
parent 2bccb06359
commit 8895d508c0
4 changed files with 290 additions and 42 deletions

View File

@@ -1,4 +1,5 @@
import { Users, CheckCircle, XCircle, AlertTriangle, Zap, Activity } from 'lucide-react'
import { useState, useEffect } from 'react'
import { Users, CheckCircle, XCircle, AlertTriangle, Zap, Activity, TrendingUp } from 'lucide-react'
import type { DashboardStats } from '../../types'
import StatsCard from './StatsCard'
@@ -9,6 +10,25 @@ interface PoolStatusProps {
}
export default function PoolStatus({ stats, loading, error }: PoolStatusProps) {
const [maxRpm, setMaxRpm] = useState<number>(0)
// 获取今日最高 RPM
useEffect(() => {
const fetchMaxRpm = async () => {
try {
const res = await fetch('/api/stats/max-rpm')
const data = await res.json()
if (data.code === 0 && data.data) {
setMaxRpm(data.data.max_rpm || 0)
}
} catch (error) {
console.error('Failed to fetch max RPM:', error)
}
}
fetchMaxRpm()
// 每次 stats 更新时也刷新 max RPM
}, [stats])
if (error) {
return (
<div className="bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl p-4">
@@ -58,7 +78,17 @@ export default function PoolStatus({ stats, loading, error }: PoolStatusProps) {
color="slate"
loading={loading}
/>
<StatsCard title="RPM" value={stats?.rpm ?? 0} icon={Zap} color="blue" loading={loading} />
{/* RPM 卡片 - 显示当前 RPM 和今日最高 */}
<div className="relative">
<StatsCard title="RPM" value={stats?.rpm ?? 0} icon={Zap} color="blue" loading={loading} />
{/* 今日最高 RPM 显示在卡片下方 */}
{maxRpm > 0 && (
<div className="absolute -bottom-5 left-0 right-0 flex items-center justify-center gap-1 text-xs text-slate-500 dark:text-slate-400">
<TrendingUp className="h-3 w-3 text-orange-500" />
<span>: <span className="font-semibold text-orange-500">{maxRpm}</span></span>
</div>
)}
</div>
</div>
)
}