Files
param-hub/admin/templates/index.html
hubian f249f28eb7 新增后台管理系统
功能模块:
- 仪表盘: 模型/GPU/CPU统计、开源/闭源分布、快速操作
- 模型管理: 查看模型列表、筛选搜索、添加新模型
- GPU管理: 查看GPU列表、厂商筛选、添加新GPU
- CPU管理: 查看CPU列表
- 数据导出: 导出模型/GPU数据为JSON

技术:
- Flask + Tailwind CSS
- 解析TypeScript数据文件
- 端口: 19006
2026-04-08 14:13:06 +08:00

202 lines
11 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>参数百科 - 后台管理</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css" rel="stylesheet">
<style>
.gradient-bg { background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%); }
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<div class="flex">
<!-- 侧边栏 -->
<aside class="w-64 bg-slate-800 min-h-screen fixed left-0 top-0">
<div class="p-6">
<h1 class="text-white text-xl font-bold flex items-center gap-2">
<i class="ri-database-2-line text-2xl text-blue-400"></i>
参数百科后台
</h1>
</div>
<nav class="mt-6">
<a href="/" class="flex items-center gap-3 px-6 py-3 bg-slate-700 text-white">
<i class="ri-dashboard-line"></i><span>仪表盘</span>
</a>
<a href="/models" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-cpu-line"></i><span>模型管理</span>
</a>
<a href="/gpus" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-dashboard-3-line"></i><span>GPU管理</span>
</a>
<a href="/cpus" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-cpu-line"></i><span>CPU管理</span>
</a>
</nav>
<div class="absolute bottom-0 left-0 right-0 p-4 border-t border-slate-700">
<a href="http://localhost:3000" target="_blank" class="text-slate-400 hover:text-white text-sm flex items-center gap-2">
<i class="ri-external-link-line"></i> 访问前台
</a>
</div>
</aside>
<!-- 主内容 -->
<main class="ml-64 flex-1 p-8">
<!-- 统计卡片 -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
<div class="bg-white rounded-xl p-6 shadow-sm border border-gray-100">
<div class="flex items-center justify-between">
<div>
<p class="text-gray-500 text-sm">模型总数</p>
<p class="text-3xl font-bold text-gray-800 mt-2" id="stat-models">-</p>
</div>
<div class="w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center">
<i class="ri-cpu-line text-2xl text-blue-600"></i>
</div>
</div>
<div class="mt-2 flex gap-4 text-xs">
<span class="text-green-600">开源: <span id="stat-open">0</span></span>
<span class="text-gray-500">闭源: <span id="stat-closed">0</span></span>
</div>
</div>
<div class="bg-white rounded-xl p-6 shadow-sm border border-gray-100">
<div class="flex items-center justify-between">
<div>
<p class="text-gray-500 text-sm">GPU总数</p>
<p class="text-3xl font-bold text-gray-800 mt-2" id="stat-gpus">-</p>
</div>
<div class="w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center">
<i class="ri-dashboard-3-line text-2xl text-green-600"></i>
</div>
</div>
<div class="mt-2 flex gap-4 text-xs">
<span class="text-green-600">NVIDIA: <span id="stat-nvidia">0</span></span>
<span class="text-red-500">AMD: <span id="stat-amd">0</span></span>
</div>
</div>
<div class="bg-white rounded-xl p-6 shadow-sm border border-gray-100">
<div class="flex items-center justify-between">
<div>
<p class="text-gray-500 text-sm">CPU总数</p>
<p class="text-3xl font-bold text-gray-800 mt-2" id="stat-cpus">-</p>
</div>
<div class="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center">
<i class="ri-cpu-line text-2xl text-purple-600"></i>
</div>
</div>
</div>
<div class="bg-white rounded-xl p-6 shadow-sm border border-gray-100">
<div class="flex items-center justify-between">
<div>
<p class="text-gray-500 text-sm">数据完整性</p>
<p class="text-2xl font-bold text-green-600 mt-2">良好</p>
</div>
<div class="w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center">
<i class="ri-check-double-line text-2xl text-green-600"></i>
</div>
</div>
</div>
</div>
<!-- 快速操作 -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="ri-lightbulb-line text-yellow-500"></i>
快速操作
</h2>
<div class="space-y-3">
<a href="/models" class="flex items-center gap-3 p-3 bg-blue-50 rounded-lg hover:bg-blue-100">
<i class="ri-add-circle-line text-blue-600"></i>
<span class="text-gray-700">添加新模型</span>
</a>
<a href="/gpus" class="flex items-center gap-3 p-3 bg-green-50 rounded-lg hover:bg-green-100">
<i class="ri-add-circle-line text-green-600"></i>
<span class="text-gray-700">添加新GPU</span>
</a>
<a href="/cpus" class="flex items-center gap-3 p-3 bg-purple-50 rounded-lg hover:bg-purple-100">
<i class="ri-add-circle-line text-purple-600"></i>
<span class="text-gray-700">添加新CPU</span>
</a>
</div>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="ri-download-line text-blue-500"></i>
数据导出
</h2>
<div class="space-y-3">
<a href="/api/export/models" class="flex items-center gap-3 p-3 bg-gray-50 rounded-lg hover:bg-gray-100">
<i class="ri-file-text-line text-gray-600"></i>
<span class="text-gray-700">导出模型数据 (JSON)</span>
</a>
<a href="/api/export/gpus" class="flex items-center gap-3 p-3 bg-gray-50 rounded-lg hover:bg-gray-100">
<i class="ri-file-text-line text-gray-600"></i>
<span class="text-gray-700">导出GPU数据 (JSON)</span>
</a>
</div>
</div>
</div>
<!-- 最近添加 -->
<div class="mt-6 bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="ri-time-line text-purple-500"></i>
最新模型
</h2>
<div id="recentModels" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<p class="text-gray-500">加载中...</p>
</div>
</div>
</main>
</div>
<script>
async function loadStats() {
const res = await fetch('/api/stats');
const data = await res.json();
document.getElementById('stat-models').textContent = data.models_count;
document.getElementById('stat-gpus').textContent = data.gpus_count;
document.getElementById('stat-cpus').textContent = data.cpus_count;
document.getElementById('stat-open').textContent = data.open_source_models;
document.getElementById('stat-closed').textContent = data.closed_source_models;
document.getElementById('stat-nvidia').textContent = data.nvidia_gpus;
document.getElementById('stat-amd').textContent = data.amd_gpus;
}
async function loadRecentModels() {
const res = await fetch('/api/models');
const models = await res.json();
const container = document.getElementById('recentModels');
if (models.length === 0) {
container.innerHTML = '<p class="text-gray-500">暂无模型数据</p>';
return;
}
container.innerHTML = models.slice(0, 6).map(m => `
<div class="p-4 bg-gray-50 rounded-lg">
<div class="flex items-center gap-2 mb-2">
<span class="font-medium text-gray-800">${m.name}</span>
${m.isOpenSource ? '<span class="text-xs px-2 py-0.5 bg-green-100 text-green-600 rounded">开源</span>' : ''}
</div>
<p class="text-sm text-gray-500">${m.organization || '未知'}</p>
<p class="text-xs text-gray-400 mt-1">
${m.parametersCount ? m.parametersCount + 'B 参数' : '参数未知'}
${m.contextLength ? ' · ' + (m.contextLength >= 1000 ? m.contextLength/1000 + 'K' : m.contextLength) + ' 上下文' : ''}
</p>
</div>
`).join('');
}
loadStats();
loadRecentModels();
</script>
</body>
</html>