feat(admin): add LLM call logs, system info, plugin list pages

- ai-core/llm: ring-buffer call logger with stats
- Gateway: /api/v1/admin/llm-calls, /system, /plugins, /sessions endpoints
- Frontend: LLMCallsPage (table + stats), SystemPage (version/plugins/sessions)
- Admin nav expanded to 7 items
This commit is contained in:
Aska committed 2026-08-12 16:56:52 +08:00
1 parent 8bfda096f7
commit 1a80ac2a00
7 files changed
+318 -1

No files matched your search

@@ -0,0 +1,80 @@
import { useEffect, useState } from 'react'
import { getToken } from '../../api/client'
export default function SystemPage() {
const [info, setInfo] = useState<any>({})
const [sessions, setSessions] = useState<any[]>([])
const [plugins, setPlugins] = useState<any[]>([])
useEffect(() => {
fetchAll()
const interval = setInterval(fetchAll, 10000)
return () => clearInterval(interval)
}, [])
const fetchAll = async () => {
const token = getToken()
const headers = { Authorization: `Bearer ${token}` }
try {
const [sysRes, sessionRes, pluginRes] = await Promise.all([
fetch('/api/v1/admin/system', { headers }),
fetch('/api/v1/admin/sessions', { headers }),
fetch('/api/v1/admin/plugins', { headers }),
])
if (sysRes.ok) setInfo((await sysRes.json()).system)
if (sessionRes.ok) setSessions((await sessionRes.json()).sessions || [])
if (pluginRes.ok) setPlugins((await pluginRes.json()).plugins || [])
} catch {}
}
return (
<div className="p-6 space-y-6">
<h2 className="text-lg font-semibold">系统信息</h2>
{/* System Info */}
<div className="grid grid-cols-4 gap-3">
<StatRow label="版本" value={info.version || '-'} />
<StatRow label="Go 版本" value={info.go_version || '-'} />
<StatRow label="运行时间" value={info.uptime_sec ? `${Math.floor(info.uptime_sec/60)}m` : '-'} />
<StatRow label="WS 连接" value={info.ws_clients ?? 0} />
</div>
{/* Plugins list */}
<div>
<h3 className="text-sm font-medium text-white/60 mb-3">已加载插件 ({plugins.length})</h3>
<div className="flex flex-wrap gap-2">
{plugins.map((p, i) => (
<span key={i} className="px-3 py-1.5 bg-[#000] border border-[#404040] rounded-full text-xs text-[#F2F2F2]">
{p.name}
</span>
))}
</div>
</div>
{/* Sessions */}
<div>
<h3 className="text-sm font-medium text-white/60 mb-3">活跃会话 ({sessions.length})</h3>
{sessions.length === 0 ? (
<p className="text-xs text-white/30">暂无活跃会话</p>
) : (
<div className="space-y-1">
{sessions.map((s: any, i) => (
<div key={i} className="bg-[#000] border border-[#404040] rounded-[14px] px-4 py-2 text-xs text-white/50">
{s.session_id || s.id || '-'}
</div>
))}
</div>
)}
</div>
</div>
)
}
function StatRow({ label, value }: { label:string; value:string|number }) {
return (
<div className="bg-[#000] border border-[#404040] rounded-[18px] px-4 py-3">
<p className="text-xs text-white/40 mb-1">{label}</p>
<p className="text-lg font-bold text-[#F2F2F2]">{value}</p>
</div>
)
}