- 新增发布日期(publish_date)、热度(views)、置顶(is_pinned)字段 - 后台管理表格显示新字段和置顶操作按钮 - 前端默认排序:置顶优先 → 发布日期最新 - 新增多种排序选项:发布日期、热度、名称等 - 新增图片上传API(支持多图上传) - 后台管理表单添加图片上传组件(支持文件选择和粘贴) - 数据创建时自动初始化新字段
279 lines
13 KiB
HTML
279 lines
13 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>ParamHub - 参数百科</title>
|
|
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<link href="https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css" rel="stylesheet">
|
|
</head>
|
|
<body class="bg-gray-50 min-h-screen">
|
|
<!-- 导航栏 -->
|
|
<nav class="bg-white shadow-sm sticky top-0 z-50">
|
|
<div class="max-w-7xl mx-auto px-4 py-3 flex justify-between items-center">
|
|
<a href="/" class="flex items-center gap-2">
|
|
<i class="ri-dashboard-3-line text-2xl text-indigo-600"></i>
|
|
<span class="text-xl font-bold text-gray-800">ParamHub</span>
|
|
</a>
|
|
<div class="flex gap-4 text-sm" id="topNav">
|
|
<!-- 动态加载 -->
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="max-w-7xl mx-auto px-4 py-8">
|
|
<!-- 页面标题 -->
|
|
<div class="mb-6">
|
|
<h1 class="text-2xl font-bold text-gray-800 flex items-center gap-2">
|
|
<i class="ri-robot-line text-indigo-600"></i>
|
|
模型数据库
|
|
</h1>
|
|
<p class="text-gray-500 mt-1">AI大模型参数规格一览</p>
|
|
</div>
|
|
|
|
<!-- 搜索和筛选 -->
|
|
<div class="bg-white rounded-xl shadow-sm p-4 mb-6">
|
|
<div class="flex gap-4 items-center">
|
|
<div class="flex-1 relative">
|
|
<i class="ri-search-line absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"></i>
|
|
<input type="text" id="searchInput" placeholder="搜索模型名称或厂商..."
|
|
class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:border-indigo-400"
|
|
oninput="loadModels()">
|
|
</div>
|
|
<select id="sortBy" class="px-4 py-2 border border-gray-200 rounded-lg" onchange="loadModels()">
|
|
<option value="default">默认排序(置顶优先)</option>
|
|
<option value="publish_date">按发布日期</option>
|
|
<option value="views">按热度</option>
|
|
<option value="name">按名称</option>
|
|
<option value="parameters">按参数量</option>
|
|
<option value="mmlu">按MMLU分数</option>
|
|
<option value="context_length">按上下文长度</option>
|
|
<option value="created_at">按创建时间</option>
|
|
</select>
|
|
<select id="sortOrder" class="px-4 py-2 border border-gray-200 rounded-lg" onchange="loadModels()">
|
|
<option value="desc">降序</option>
|
|
<option value="asc">升序</option>
|
|
</select>
|
|
<select id="filterType" class="px-4 py-2 border border-gray-200 rounded-lg" onchange="loadModels()">
|
|
<option value="all">全部</option>
|
|
<option value="open">开源</option>
|
|
<option value="closed">商业</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 模型列表 -->
|
|
<div class="bg-white rounded-xl shadow-sm overflow-hidden">
|
|
<table class="w-full">
|
|
<thead class="bg-gray-50 border-b">
|
|
<tr>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">模型名称</th>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">厂商</th>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">参数量</th>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">上下文</th>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">MMLU</th>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">类型</th>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">价格</th>
|
|
<th class="px-4 py-3 text-center text-sm font-medium text-gray-600">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="modelsTable">
|
|
<tr><td colspan="8" class="text-center text-gray-400 py-8">加载中...</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</main>
|
|
|
|
<!-- 详情弹窗 -->
|
|
<div id="detailModal" class="fixed inset-0 bg-black/50 z-50 hidden flex items-center justify-center">
|
|
<div class="bg-white rounded-xl max-w-2xl w-full mx-4 max-h-[80vh] overflow-auto">
|
|
<div class="p-6 border-b flex justify-between items-center">
|
|
<h2 class="text-xl font-bold text-gray-800" id="modalTitle">模型详情</h2>
|
|
<button onclick="closeModal()" class="text-gray-400 hover:text-gray-600">
|
|
<i class="ri-close-line text-2xl"></i>
|
|
</button>
|
|
</div>
|
|
<div id="modalContent" class="p-6"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
let allModels = [];
|
|
let categories = [];
|
|
|
|
// 加载导航栏
|
|
async function loadNav() {
|
|
const res = await fetch('/api/categories');
|
|
categories = await res.json();
|
|
|
|
const builtinPages = [
|
|
{name: '首页', href: '/'},
|
|
{name: '工具', href: '/tools'},
|
|
{name: '对比', href: '/compare'},
|
|
{name: '知识库', href: '/knowledge'}
|
|
];
|
|
|
|
const categoryPages = {
|
|
'ai-models': '/models',
|
|
'gpus': '/gpus',
|
|
'cpus': '/cpus'
|
|
};
|
|
|
|
let navHtml = '';
|
|
builtinPages.forEach(p => {
|
|
const isActive = window.location.pathname === p.href;
|
|
navHtml += `<a href="${p.href}" class="${isActive ? 'text-indigo-600 font-medium' : 'text-gray-600 hover:text-indigo-600'}">${p.name}</a>`;
|
|
});
|
|
|
|
categories.forEach(cat => {
|
|
const href = categoryPages[cat.id] || `/category/${cat.id}`;
|
|
const isActive = window.location.pathname === href;
|
|
navHtml += `<a href="${href}" class="${isActive ? 'text-indigo-600 font-medium' : 'text-gray-600 hover:text-indigo-600'}">${cat.name}</a>`;
|
|
});
|
|
|
|
document.getElementById('topNav').innerHTML = navHtml;
|
|
}
|
|
|
|
async function loadModels() {
|
|
const keyword = document.getElementById('searchInput').value.trim();
|
|
const sortBy = document.getElementById('sortBy').value;
|
|
const sortOrder = document.getElementById('sortOrder').value;
|
|
const filterType = document.getElementById('filterType').value;
|
|
|
|
let url = `/api/models?sort=${sortBy}&order=${sortOrder}`;
|
|
if (keyword) url += `&q=${encodeURIComponent(keyword)}`;
|
|
|
|
const res = await fetch(url);
|
|
let models = await res.json();
|
|
allModels = models;
|
|
|
|
// 本地过滤类型
|
|
if (filterType === 'open') {
|
|
models = models.filter(m => m.is_open_source);
|
|
} else if (filterType === 'closed') {
|
|
models = models.filter(m => !m.is_open_source);
|
|
}
|
|
|
|
renderModels(models);
|
|
}
|
|
|
|
function renderModels(models) {
|
|
if (models.length === 0) {
|
|
document.getElementById('modelsTable').innerHTML = `
|
|
<tr><td colspan="8" class="text-center text-gray-400 py-8">暂无数据</td></tr>
|
|
`;
|
|
return;
|
|
}
|
|
|
|
const html = models.map(m => `
|
|
<tr class="border-b hover:bg-gray-50 transition ${m.is_pinned ? 'bg-yellow-50' : ''}">
|
|
<td class="px-4 py-3">
|
|
<div class="flex items-center gap-2">
|
|
${m.is_pinned ? '<i class="ri-pushpin-fill text-yellow-500" title="置顶"></i>' : ''}
|
|
<div>
|
|
<div class="font-medium text-gray-800">${m.name}</div>
|
|
<div class="text-xs text-gray-500">${m.architecture || ''}</div>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="px-4 py-3 text-gray-600">${m.organization}</td>
|
|
<td class="px-4 py-3">
|
|
<span class="px-2 py-1 bg-blue-100 text-blue-700 rounded text-sm">${m.parameters}B</span>
|
|
</td>
|
|
<td class="px-4 py-3 text-gray-600">${formatContext(m.context_length)}</td>
|
|
<td class="px-4 py-3">
|
|
<span class="px-2 py-1 bg-green-100 text-green-700 rounded text-sm">${m.mmlu || '-'}%</span>
|
|
</td>
|
|
<td class="px-4 py-3">
|
|
${m.is_open_source
|
|
? '<span class="px-2 py-1 bg-emerald-100 text-emerald-700 rounded text-sm">开源</span>'
|
|
: '<span class="px-2 py-1 bg-gray-100 text-gray-700 rounded text-sm">商业</span>'}
|
|
</td>
|
|
<td class="px-4 py-3 text-sm text-gray-600">
|
|
${m.input_price ? `$${m.input_price}/$${m.output_price}` : '免费'}
|
|
</td>
|
|
<td class="px-4 py-3 text-center">
|
|
<button onclick="showDetail('${m.id}')" class="text-indigo-600 hover:text-indigo-800 text-sm">
|
|
<i class="ri-eye-line mr-1"></i>详情
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
`).join('');
|
|
|
|
document.getElementById('modelsTable').innerHTML = html;
|
|
}
|
|
|
|
function formatContext(len) {
|
|
if (!len) return '-';
|
|
if (len >= 1000000) return (len / 1000) + 'K';
|
|
if (len >= 1000) return (len / 1000) + 'K';
|
|
return len;
|
|
}
|
|
|
|
async function showDetail(id) {
|
|
const res = await fetch(`/api/models/${id}`);
|
|
const model = await res.json();
|
|
|
|
document.getElementById('modalTitle').textContent = model.name;
|
|
document.getElementById('modalContent').innerHTML = `
|
|
<div class="grid grid-cols-2 gap-4">
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-sm text-gray-500">厂商</div>
|
|
<div class="font-medium text-gray-800 mt-1">${model.organization}</div>
|
|
</div>
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-sm text-gray-500">架构</div>
|
|
<div class="font-medium text-gray-800 mt-1">${model.architecture || '-'}</div>
|
|
</div>
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-sm text-gray-500">参数量</div>
|
|
<div class="font-medium text-gray-800 mt-1">${model.parameters}B</div>
|
|
</div>
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-sm text-gray-500">上下文长度</div>
|
|
<div class="font-medium text-gray-800 mt-1">${formatContext(model.context_length)}</div>
|
|
</div>
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-sm text-gray-500">MMLU分数</div>
|
|
<div class="font-medium text-gray-800 mt-1">${model.mmlu || '-'}%</div>
|
|
</div>
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-sm text-gray-500">HumanEval</div>
|
|
<div class="font-medium text-gray-800 mt-1">${model.humaneval || '-'}%</div>
|
|
</div>
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-sm text-gray-500">许可证</div>
|
|
<div class="font-medium text-gray-800 mt-1">${model.license || '-'}</div>
|
|
</div>
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-sm text-gray-500">API价格</div>
|
|
<div class="font-medium text-gray-800 mt-1">
|
|
${model.input_price ? `输入: $${model.input_price}/1K 输出: $${model.output_price}/1K` : '免费'}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="mt-4 p-4 bg-blue-50 rounded-lg">
|
|
<div class="text-sm text-blue-600">简介</div>
|
|
<div class="text-gray-800 mt-1">${model.description || '暂无描述'}</div>
|
|
</div>
|
|
`;
|
|
|
|
document.getElementById('detailModal').classList.remove('hidden');
|
|
}
|
|
|
|
function closeModal() {
|
|
document.getElementById('detailModal').classList.add('hidden');
|
|
}
|
|
|
|
// 点击弹窗外部关闭
|
|
document.getElementById('detailModal').addEventListener('click', function(e) {
|
|
if (e.target === this) closeModal();
|
|
});
|
|
|
|
// 初始化
|
|
loadNav();
|
|
loadModels();
|
|
</script>
|
|
</body>
|
|
</html> |