import { useAuth } from "@/_core/hooks/useAuth"; import { trpc } from "@/lib/trpc"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Skeleton } from "@/components/ui/skeleton"; import { Award, TrendingUp, Target, Zap, Footprints, Activity, Wind } from "lucide-react"; import { ResponsiveContainer, RadarChart, PolarGrid, PolarAngleAxis, PolarRadiusAxis, Radar, AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, Legend } from "recharts"; const NTRP_LEVELS = [ { min: 1.0, max: 1.5, label: "初学者", desc: "刚开始学习网球,正在学习基本击球动作", color: "bg-gray-100 text-gray-700" }, { min: 1.5, max: 2.0, label: "初级", desc: "能够进行简单的来回击球,但缺乏一致性", color: "bg-orange-100 text-orange-700" }, { min: 2.0, max: 2.5, label: "初中级", desc: "击球更加稳定,开始理解基本策略", color: "bg-yellow-100 text-yellow-700" }, { min: 2.5, max: 3.0, label: "中级", desc: "能够稳定地进行中速击球,具备基本的网前技术", color: "bg-green-100 text-green-700" }, { min: 3.0, max: 3.5, label: "中高级", desc: "击球力量和控制力增强,开始使用旋转", color: "bg-blue-100 text-blue-700" }, { min: 3.5, max: 4.0, label: "高级", desc: "具备全面的技术,能够在比赛中运用战术", color: "bg-indigo-100 text-indigo-700" }, { min: 4.0, max: 4.5, label: "高级竞技", desc: "技术精湛,具备强大的进攻和防守能力", color: "bg-purple-100 text-purple-700" }, { min: 4.5, max: 5.0, label: "专业水平", desc: "接近职业水平,全面的技术和战术能力", color: "bg-red-100 text-red-700" }, ]; function getNTRPLevel(rating: number) { return NTRP_LEVELS.find(l => rating >= l.min && rating < l.max) || NTRP_LEVELS[0]; } export default function Rating() { const { user } = useAuth(); const { data: ratingData } = trpc.rating.current.useQuery(); const { data: history, isLoading } = trpc.rating.history.useQuery(); const { data: stats } = trpc.profile.stats.useQuery(); const currentRating = ratingData?.rating || 1.5; const level = getNTRPLevel(currentRating); // Get latest dimension scores const latestWithDimensions = history?.find((h: any) => h.dimensionScores); const dimensions = (latestWithDimensions as any)?.dimensionScores || {}; const radarData = [ { dimension: "姿势准确", value: dimensions.poseAccuracy || 0, fullMark: 100 }, { dimension: "击球一致", value: dimensions.strokeConsistency || 0, fullMark: 100 }, { dimension: "脚步移动", value: dimensions.footwork || 0, fullMark: 100 }, { dimension: "动作流畅", value: dimensions.fluidity || 0, fullMark: 100 }, { dimension: "力量", value: dimensions.power || 0, fullMark: 100 }, ]; const trendData = (history || []).map((h: any) => ({ date: new Date(h.createdAt).toLocaleDateString("zh-CN", { month: "short", day: "numeric" }), rating: h.rating, })); if (isLoading) { return (
基于所有历史训练记录自动计算的综合评分
{level.desc}
完成视频分析后将显示能力雷达图
完成视频分析后将显示评分趋势
{item.value ? Math.round(item.value) : "--"}
权重 {item.weight}
{item.desc}
{l.desc}