功能更新: - 新增智能添加功能:粘贴文本自动解析为结构化数据 - 新增展示开关:各分类和产品支持显示/隐藏控制 - 保留原始数据:智能添加的产品保留raw_text字段 - 优化价格显示:支持多币种、价格区间、单位 - 修复图标问题:CPU图标改为ri-cpu-line - 新增favicon:所有页面添加浏览器标签图标 技术改进: - 新增大模型API集成(LLM Proxy) - 新增smart-add API接口 - 新增visible字段和toggle API - 优化前端表格显示
217 lines
10 KiB
HTML
217 lines
10 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-cpu-line text-purple-600"></i>
|
|
CPU数据库
|
|
</h1>
|
|
<p class="text-gray-500 mt-1">处理器规格参数一览</p>
|
|
</div>
|
|
|
|
<div class="bg-white rounded-xl shadow-sm p-4 mb-6">
|
|
<div class="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="搜索CPU名称或厂商..."
|
|
class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:border-purple-400"
|
|
oninput="loadCpus()">
|
|
</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">CPU名称</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">L3缓存</th>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-600">TDP</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="cpusTable">
|
|
<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">CPU详情</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 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 loadCpus() {
|
|
const keyword = document.getElementById('searchInput').value.trim();
|
|
let url = '/api/cpus';
|
|
if (keyword) url += `?q=${encodeURIComponent(keyword)}`;
|
|
|
|
const res = await fetch(url);
|
|
const cpus = await res.json();
|
|
|
|
if (cpus.length === 0) {
|
|
document.getElementById('cpusTable').innerHTML = `
|
|
<tr><td colspan="8" class="text-center text-gray-400 py-8">暂无数据</td></tr>
|
|
`;
|
|
return;
|
|
}
|
|
|
|
const html = cpus.map(c => `
|
|
<tr class="border-b hover:bg-gray-50 transition">
|
|
<td class="px-4 py-3">
|
|
<div class="font-medium text-gray-800">${c.name}</div>
|
|
<div class="text-xs text-gray-500">${c.release_year || ''}</div>
|
|
</td>
|
|
<td class="px-4 py-3 text-gray-600">${c.manufacturer}</td>
|
|
<td class="px-4 py-3">
|
|
<span class="px-2 py-1 bg-purple-100 text-purple-700 rounded text-sm">${c.cores}/${c.threads}</span>
|
|
</td>
|
|
<td class="px-4 py-3 text-gray-600">${c.base_clock_ghz}-${c.boost_clock_ghz}GHz</td>
|
|
<td class="px-4 py-3 text-gray-600">${c.l3_cache_mb}MB</td>
|
|
<td class="px-4 py-3 text-gray-600">${c.tdp_watts}W</td>
|
|
<td class="px-4 py-3 text-gray-600">$${c.price_usd || '-'}</td>
|
|
<td class="px-4 py-3 text-center">
|
|
<button onclick="showDetail('${c.id}')" class="text-purple-600 hover:text-purple-800 text-sm">
|
|
<i class="ri-eye-line mr-1"></i>详情
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
`).join('');
|
|
|
|
document.getElementById('cpusTable').innerHTML = html;
|
|
}
|
|
|
|
async function showDetail(id) {
|
|
const res = await fetch(`/api/cpus/${id}`);
|
|
const cpu = await res.json();
|
|
|
|
document.getElementById('modalTitle').textContent = cpu.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">${cpu.manufacturer}</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">${cpu.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">${cpu.cores}</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">${cpu.threads}</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">${cpu.base_clock_ghz}GHz</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">${cpu.boost_clock_ghz}GHz</div>
|
|
</div>
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-sm text-gray-500">L3缓存</div>
|
|
<div class="font-medium text-gray-800 mt-1">${cpu.l3_cache_mb}MB</div>
|
|
</div>
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<div class="text-sm text-gray-500">TDP功耗</div>
|
|
<div class="font-medium text-gray-800 mt-1">${cpu.tdp_watts}W</div>
|
|
</div>
|
|
<div class="p-4 bg-gray-50 rounded-lg col-span-2">
|
|
<div class="text-sm text-gray-500">价格</div>
|
|
<div class="font-medium text-gray-800 mt-1">$${cpu.price_usd || '-'}</div>
|
|
</div>
|
|
</div>
|
|
<div class="mt-4 p-4 bg-purple-50 rounded-lg">
|
|
<div class="text-sm text-purple-600">简介</div>
|
|
<div class="text-gray-800 mt-1">${cpu.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();
|
|
loadCpus();
|
|
</script>
|
|
</body>
|
|
</html> |