功能更新: - 新增智能添加功能:粘贴文本自动解析为结构化数据 - 新增展示开关:各分类和产品支持显示/隐藏控制 - 保留原始数据:智能添加的产品保留raw_text字段 - 优化价格显示:支持多币种、价格区间、单位 - 修复图标问题:CPU图标改为ri-cpu-line - 新增favicon:所有页面添加浏览器标签图标 技术改进: - 新增大模型API集成(LLM Proxy) - 新增smart-add API接口 - 新增visible字段和toggle API - 优化前端表格显示
238 lines
11 KiB
HTML
238 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>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-git-merge-line text-purple-600"></i>
|
|
对比工具
|
|
</h1>
|
|
<p class="text-gray-500 mt-1">多维度对比模型或硬件参数</p>
|
|
</div>
|
|
|
|
<!-- 对比类型选择 -->
|
|
<div class="bg-white rounded-xl shadow-sm p-4 mb-6">
|
|
<div class="flex gap-4">
|
|
<button onclick="setCompareType('model')" id="btnModel" class="px-4 py-2 bg-indigo-600 text-white rounded-lg">
|
|
<i class="ri-robot-line mr-2"></i>模型对比
|
|
</button>
|
|
<button onclick="setCompareType('gpu')" id="btnGpu" class="px-4 py-2 bg-gray-200 text-gray-600 rounded-lg hover:bg-gray-300">
|
|
<i class="ri-cpu-line mr-2"></i>GPU对比
|
|
</button>
|
|
<button onclick="setCompareType('cpu')" id="btnCpu" class="px-4 py-2 bg-gray-200 text-gray-600 rounded-lg hover:bg-gray-300">
|
|
<i class="ri-cpu-line mr-2"></i>CPU对比
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 选择列表 -->
|
|
<div class="grid grid-cols-2 gap-4 mb-6">
|
|
<div class="bg-white rounded-xl shadow-sm p-4">
|
|
<label class="text-sm font-medium text-gray-600 mb-2 block">选择第一项</label>
|
|
<select id="select1" class="w-full px-4 py-2 border border-gray-200 rounded-lg" onchange="compare()">
|
|
<option value="">请选择...</option>
|
|
</select>
|
|
</div>
|
|
<div class="bg-white rounded-xl shadow-sm p-4">
|
|
<label class="text-sm font-medium text-gray-600 mb-2 block">选择第二项</label>
|
|
<select id="select2" class="w-full px-4 py-2 border border-gray-200 rounded-lg" onchange="compare()">
|
|
<option value="">请选择...</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 对比结果 -->
|
|
<div id="compareResult" class="bg-white rounded-xl shadow-sm p-6 hidden">
|
|
<h2 class="text-lg font-semibold text-gray-800 mb-4">对比结果</h2>
|
|
<div id="compareTable"></div>
|
|
</div>
|
|
</main>
|
|
|
|
<script>
|
|
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;
|
|
}
|
|
let compareType = 'model';
|
|
let allData = [];
|
|
|
|
async function setCompareType(type) {
|
|
compareType = type;
|
|
|
|
// 更新按钮样式
|
|
document.getElementById('btnModel').className = type === 'model'
|
|
? 'px-4 py-2 bg-indigo-600 text-white rounded-lg'
|
|
: 'px-4 py-2 bg-gray-200 text-gray-600 rounded-lg hover:bg-gray-300';
|
|
document.getElementById('btnGpu').className = type === 'gpu'
|
|
? 'px-4 py-2 bg-green-600 text-white rounded-lg'
|
|
: 'px-4 py-2 bg-gray-200 text-gray-600 rounded-lg hover:bg-gray-300';
|
|
document.getElementById('btnCpu').className = type === 'cpu'
|
|
? 'px-4 py-2 bg-purple-600 text-white rounded-lg'
|
|
: 'px-4 py-2 bg-gray-200 text-gray-600 rounded-lg hover:bg-gray-300';
|
|
|
|
// 加载数据
|
|
const res = await fetch(`/api/${type}s`);
|
|
allData = await res.json();
|
|
|
|
// 填充下拉框
|
|
const select1 = document.getElementById('select1');
|
|
const select2 = document.getElementById('select2');
|
|
|
|
select1.innerHTML = '<option value="">请选择...</option>' +
|
|
allData.map(d => `<option value="${d.id}">${d.name}</option>`).join('');
|
|
select2.innerHTML = '<option value="">请选择...</option>' +
|
|
allData.map(d => `<option value="${d.id}">${d.name}</option>`).join('');
|
|
|
|
document.getElementById('compareResult').classList.add('hidden');
|
|
}
|
|
|
|
async function compare() {
|
|
const id1 = document.getElementById('select1').value;
|
|
const id2 = document.getElementById('select2').value;
|
|
|
|
if (!id1 || !id2) {
|
|
document.getElementById('compareResult').classList.add('hidden');
|
|
return;
|
|
}
|
|
|
|
const res1 = await fetch(`/api/${compareType}s/${id1}`);
|
|
const res2 = await fetch(`/api/${compareType}s/${id2}`);
|
|
|
|
const item1 = await res1.json();
|
|
const item2 = await res2.json();
|
|
|
|
let fields = [];
|
|
if (compareType === 'model') {
|
|
fields = [
|
|
{ key: 'name', label: '名称' },
|
|
{ key: 'organization', label: '厂商' },
|
|
{ key: 'parameters', label: '参数量(B)', unit: 'B' },
|
|
{ key: 'context_length', label: '上下文长度' },
|
|
{ key: 'mmlu', label: 'MMLU分数', unit: '%' },
|
|
{ key: 'humaneval', label: 'HumanEval', unit: '%' },
|
|
{ key: 'is_open_source', label: '类型', format: v => v ? '开源' : '商业' },
|
|
{ key: 'input_price', label: '输入价格', unit: '$/1K' },
|
|
{ key: 'output_price', label: '输出价格', unit: '$/1K' },
|
|
];
|
|
} else if (compareType === 'gpu') {
|
|
fields = [
|
|
{ key: 'name', label: '名称' },
|
|
{ key: 'manufacturer', label: '厂商' },
|
|
{ key: 'architecture', label: '架构' },
|
|
{ key: 'memory_gb', label: '显存', unit: 'GB' },
|
|
{ key: 'cuda_cores', label: 'CUDA核心' },
|
|
{ key: 'fp16_tflops', label: 'FP16性能', unit: 'TF' },
|
|
{ key: 'price_usd', label: '价格', unit: '$' },
|
|
];
|
|
} else {
|
|
fields = [
|
|
{ key: 'name', label: '名称' },
|
|
{ key: 'manufacturer', label: '厂商' },
|
|
{ key: 'cores', label: '核心数' },
|
|
{ key: 'threads', label: '线程数' },
|
|
{ key: 'base_clock_ghz', label: '基础频率', unit: 'GHz' },
|
|
{ key: 'boost_clock_ghz', label: '加速频率', unit: 'GHz' },
|
|
{ key: 'l3_cache_mb', label: 'L3缓存', unit: 'MB' },
|
|
{ key: 'tdp_watts', label: 'TDP', unit: 'W' },
|
|
{ key: 'price_usd', label: '价格', unit: '$' },
|
|
];
|
|
}
|
|
|
|
const html = `
|
|
<table class="w-full">
|
|
<thead class="bg-gray-50">
|
|
<tr>
|
|
<th class="px-4 py-2 text-left text-sm font-medium text-gray-600">参数</th>
|
|
<th class="px-4 py-2 text-center text-sm font-medium text-gray-600">${item1.name}</th>
|
|
<th class="px-4 py-2 text-center text-sm font-medium text-gray-600">${item2.name}</th>
|
|
<th class="px-4 py-2 text-center text-sm font-medium text-gray-600">差异</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y">
|
|
${fields.map(f => {
|
|
const v1 = item1[f.key] || '-';
|
|
const v2 = item2[f.key] || '-';
|
|
const fv1 = f.format ? f.format(v1) : (v1 + (f.unit && typeof v1 === 'number' ? f.unit : ''));
|
|
const fv2 = f.format ? f.format(v2) : (v2 + (f.unit && typeof v2 === 'number' ? f.unit : ''));
|
|
|
|
let diff = '';
|
|
if (typeof v1 === 'number' && typeof v2 === 'number') {
|
|
const d = v2 - v1;
|
|
diff = d > 0 ? `<span class="text-green-600">+${d}${f.unit || ''}</span>` :
|
|
d < 0 ? `<span class="text-red-600">${d}${f.unit || ''}</span>` : '-';
|
|
}
|
|
|
|
return `
|
|
<tr>
|
|
<td class="px-4 py-2 text-gray-600">${f.label}</td>
|
|
<td class="px-4 py-2 text-center font-medium">${fv1}</td>
|
|
<td class="px-4 py-2 text-center font-medium">${fv2}</td>
|
|
<td class="px-4 py-2 text-center">${diff}</td>
|
|
</tr>
|
|
`;
|
|
}).join('')}
|
|
</tbody>
|
|
</table>
|
|
`;
|
|
|
|
document.getElementById('compareTable').innerHTML = html;
|
|
document.getElementById('compareResult').classList.remove('hidden');
|
|
}
|
|
|
|
// 初始化
|
|
loadNav();
|
|
setCompareType('model');
|
|
</script>
|
|
</body>
|
|
</html> |