Skip to content

Commit b4e9047

Browse files
author
CodeJudge
committed
feat: 活跃用户排行
1 parent 8e73a5e commit b4e9047

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

frontend/src/pages/Admin.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState, useEffect, useCallback } from 'react';
22
import { useNavigate, Link } from 'react-router-dom';
3-
import { Plus, Edit, Trash2, Users, Shield, Code, BarChart3, AlertTriangle, Loader2, Activity, Percent, Clock, Download, Upload } from 'lucide-react';
3+
import { Plus, Edit, Trash2, Users, Shield, Code, BarChart3, AlertTriangle, Loader2, Activity, Percent, Clock, Download, Upload, Trophy } from 'lucide-react';
44
import toast from 'react-hot-toast';
55
import { useAuth } from '../context/AuthContext';
66
import api from '../services/api';
@@ -275,6 +275,35 @@ export default function Admin() {
275275
</div>
276276
)}
277277

278+
{/* Top Users */}
279+
{adminStats?.topUsers && adminStats.topUsers.length > 0 && (
280+
<div className="card p-6 mb-6">
281+
<h2 className="text-lg font-semibold text-white mb-4 flex items-center gap-2">
282+
<Trophy className="w-5 h-5 text-amber-400" /> 活跃用户 Top 10
283+
</h2>
284+
<div className="overflow-x-auto">
285+
<table className="w-full text-sm">
286+
<thead>
287+
<tr className="border-b border-dark-700">
288+
<th className="text-left py-2 px-3 text-dark-400">#</th>
289+
<th className="text-left py-2 px-3 text-dark-400">用户名</th>
290+
<th className="text-right py-2 px-3 text-dark-400">提交次数</th>
291+
</tr>
292+
</thead>
293+
<tbody>
294+
{adminStats.topUsers.map((u: any, i: number) => (
295+
<tr key={i} className="border-b border-dark-800">
296+
<td className="py-2 px-3 text-dark-400">{i + 1}</td>
297+
<td className="py-2 px-3 text-white">{u.username}</td>
298+
<td className="py-2 px-3 text-dark-300 text-right">{u.submission_count}</td>
299+
</tr>
300+
))}
301+
</tbody>
302+
</table>
303+
</div>
304+
</div>
305+
)}
306+
278307
{/* System Info */}
279308
{systemInfo && (
280309
<div className="card p-6 mb-6">

0 commit comments

Comments
 (0)