Skip to content

Commit 4452f10

Browse files
author
CodeJudge
committed
feat: 管理后台系统状态
1 parent 2909e0a commit 4452f10

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

frontend/src/pages/Admin.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default function Admin() {
2323
const [allLoading, setAllLoading] = useState(false);
2424
const [dbOptimizing, setDbOptimizing] = useState(false);
2525
const [rejudgingId, setRejudgingId] = useState<number | null>(null);
26+
const [systemInfo, setSystemInfo] = useState<any>(null);
2627

2728
const fetchData = useCallback(async () => {
2829
setLoading(true);
@@ -44,6 +45,10 @@ export default function Admin() {
4445
const userRes = await fetch('/api/auth/admin/users', { headers: { Authorization: `Bearer ${localStorage.getItem('oj_token')}` } });
4546
if (userRes.ok) setUsers((await userRes.json()).users);
4647
} catch {}
48+
try {
49+
const healthRes = await fetch('/api/health');
50+
if (healthRes.ok) setSystemInfo(await healthRes.json());
51+
} catch {}
4752
}
4853
} catch (err: any) {
4954
const msg = err.message || '加载数据失败';
@@ -270,6 +275,36 @@ export default function Admin() {
270275
</div>
271276
)}
272277

278+
{/* System Info */}
279+
{systemInfo && (
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+
<Activity className="w-5 h-5 text-green-400" /> 系统状态
283+
</h2>
284+
<div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
285+
<div>
286+
<p className="text-xs text-dark-500">运行时间</p>
287+
<p className="text-sm text-white font-mono">{systemInfo.uptime || '-'}</p>
288+
</div>
289+
<div>
290+
<p className="text-xs text-dark-500">版本</p>
291+
<p className="text-sm text-white font-mono">{systemInfo.version || '-/-'}</p>
292+
</div>
293+
<div>
294+
<p className="text-xs text-dark-500">状态</p>
295+
<p className="text-sm text-green-400 flex items-center gap-1">
296+
<span className="w-2 h-2 rounded-full bg-green-400 inline-block" />
297+
运行中
298+
</p>
299+
</div>
300+
<div>
301+
<p className="text-xs text-dark-500">数据库</p>
302+
<p className="text-sm text-white font-mono">SQLite</p>
303+
</div>
304+
</div>
305+
</div>
306+
)}
307+
273308
{/* Database Tools */}
274309
{user?.role === 'admin' && (
275310
<div className="card p-6 mb-6">

0 commit comments

Comments
 (0)