|
1 | 1 | import { useState, useEffect } from 'react'; |
2 | 2 | import { Link, useNavigate } from 'react-router-dom'; |
3 | | -import { User, Mail, Shield, Award, TrendingUp, Loader2, AlertTriangle, CheckCircle2, XCircle, Clock, Zap, Lock, Key, CalendarDays, Code, PieChart, Trash2, Trophy, LogIn } from 'lucide-react'; |
| 3 | +import { User, Mail, Shield, Award, TrendingUp, Loader2, AlertTriangle, CheckCircle2, XCircle, Clock, Zap, Lock, Key, CalendarDays, Code, PieChart, Trash2, Trophy, LogIn, Flame } from 'lucide-react'; |
4 | 4 | import { useAuth } from '../context/AuthContext'; |
5 | 5 | import api from '../services/api'; |
6 | 6 | import toast from 'react-hot-toast'; |
@@ -340,6 +340,30 @@ export default function Profile() { |
340 | 340 | </div> |
341 | 341 | )} |
342 | 342 |
|
| 343 | + {/* Achievements */} |
| 344 | + <div className="card p-6"> |
| 345 | + <h3 className="text-sm font-semibold text-dark-200 mb-3 flex items-center gap-2"> |
| 346 | + <Trophy className="w-4 h-4 text-amber-400" /> 成就 |
| 347 | + </h3> |
| 348 | + <div className="grid grid-cols-2 sm:grid-cols-4 gap-3"> |
| 349 | + {[ |
| 350 | + { icon: Zap, label: '初次通过', earned: stats.accepted > 0, color: 'text-blue-400', bg: 'bg-blue-500/10' }, |
| 351 | + { icon: Trophy, label: '10题通过', earned: stats.accepted >= 10, color: 'text-amber-400', bg: 'bg-amber-500/10' }, |
| 352 | + { icon: Trophy, label: '50题通过', earned: stats.accepted >= 50, color: 'text-purple-400', bg: 'bg-purple-500/10' }, |
| 353 | + { icon: Award, label: '100题通过', earned: stats.accepted >= 100, color: 'text-emerald-400', bg: 'bg-emerald-500/10' }, |
| 354 | + { icon: Flame, label: '连续7天', earned: streak >= 7, color: 'text-orange-400', bg: 'bg-orange-500/10' }, |
| 355 | + { icon: Flame, label: '连续30天', earned: streak >= 30, color: 'text-red-400', bg: 'bg-red-500/10' }, |
| 356 | + { icon: TrendingUp, label: '通过率>80%', earned: acceptanceRate >= 80 && stats.total >= 10, color: 'text-cyan-400', bg: 'bg-cyan-500/10' }, |
| 357 | + { icon: Code, label: `#${stats.accepted}题`, earned: true, color: 'text-dark-400', bg: 'bg-dark-700/50' }, |
| 358 | + ].map((a) => ( |
| 359 | + <div key={a.label} className={`flex flex-col items-center gap-1.5 p-3 rounded-lg border ${a.earned ? `${a.bg} border-${a.color.replace('text-', '')}/20` : 'bg-dark-800/30 border-dark-700/50 opacity-40'}`}> |
| 360 | + <a.icon className={`w-6 h-6 ${a.earned ? a.color : 'text-dark-600'}`} /> |
| 361 | + <span className={`text-[10px] font-medium ${a.earned ? 'text-dark-200' : 'text-dark-600'}`}>{a.label}</span> |
| 362 | + </div> |
| 363 | + ))} |
| 364 | + </div> |
| 365 | + </div> |
| 366 | + |
343 | 367 | <DailyGoal /> |
344 | 368 | <GamificationSection /> |
345 | 369 |
|
|
0 commit comments