import { useAuth } from "@/_core/hooks/useAuth"; import { trpc } from "@/lib/trpc"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Progress } from "@/components/ui/progress"; import { Skeleton } from "@/components/ui/skeleton"; import { Target, Video, Activity, TrendingUp, Award, Clock, Zap, BarChart3, ChevronRight } from "lucide-react"; import { useLocation } from "wouter"; import { ResponsiveContainer, LineChart, Line, XAxis, YAxis, Tooltip, CartesianGrid, AreaChart, Area } from "recharts"; function NTRPBadge({ rating }: { rating: number }) { let level = "初学者"; let color = "bg-gray-100 text-gray-700"; if (rating >= 4.0) { level = "高级竞技"; color = "bg-purple-100 text-purple-700"; } else if (rating >= 3.0) { level = "中高级"; color = "bg-blue-100 text-blue-700"; } else if (rating >= 2.5) { level = "中级"; color = "bg-green-100 text-green-700"; } else if (rating >= 2.0) { level = "初中级"; color = "bg-yellow-100 text-yellow-700"; } else if (rating >= 1.5) { level = "初级"; color = "bg-orange-100 text-orange-700"; } return ( NTRP {rating.toFixed(1)} · {level} ); } export default function Dashboard() { const { user } = useAuth(); const { data: stats, isLoading } = trpc.profile.stats.useQuery(); const [, setLocation] = useLocation(); if (isLoading) { return (
{[1, 2, 3, 4].map(i => )}
); } const ratingData = stats?.ratingHistory?.map((r: any) => ({ date: new Date(r.createdAt).toLocaleDateString("zh-CN", { month: "short", day: "numeric" }), rating: r.rating, ...((r.dimensionScores as any) || {}), })) || []; return (

当前用户:{user?.name || "未命名用户"}

已完成 {stats?.totalSessions || 0} 次训练
{/* Stats cards */}

NTRP评分

{(stats?.ntrpRating || 1.5).toFixed(1)}

训练次数

{stats?.totalSessions || 0}

训练时长

{stats?.totalMinutes || 0}分钟

总击球数

{stats?.totalShots || 0}

{/* Rating trend chart */}
NTRP评分趋势
{ratingData.length > 0 ? ( ) : (

完成视频分析后将显示评分趋势

)}
{/* Recent analyses */}
{(stats?.recentAnalyses?.length || 0) > 0 ? (
{stats!.recentAnalyses.slice(0, 4).map((a: any) => (
{Math.round(a.overallScore || 0)}

{a.exerciseType || "综合分析"}

{new Date(a.createdAt).toLocaleDateString("zh-CN")} {a.shotCount ? ` · ${a.shotCount}次击球` : ""}

{Math.round(a.overallScore || 0)}分
))}
) : (
)}
{/* Quick actions */} 常用入口
); }