新功能: - 后台管理新增'网站配置'菜单 - 支持配置:网站名称、副标题、备案号、联系邮箱、GitHub、页脚文字 - 前台页面自动读取配置显示 - 页脚支持备案号链接 配置存储在 data/config.json
252 lines
11 KiB
HTML
252 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 id="pageTitle">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">
|
|
<div 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" id="navSiteName">ParamHub</span>
|
|
<span class="text-sm text-gray-500" id="navSiteSubtitle">参数百科</span>
|
|
</div>
|
|
<div class="flex gap-4 text-sm" id="navLinks">
|
|
<!-- 动态加载 -->
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- 主内容 -->
|
|
<main class="max-w-7xl mx-auto px-4 py-8">
|
|
<!-- 搜索框 -->
|
|
<div class="bg-white rounded-xl shadow-sm p-6 mb-8">
|
|
<div class="flex gap-4">
|
|
<div class="flex-1 relative">
|
|
<i class="ri-search-line absolute left-4 top-1/2 -translate-y-1/2 text-gray-400"></i>
|
|
<input type="text" id="searchInput" placeholder="搜索参数..."
|
|
class="w-full pl-12 pr-4 py-3 border border-gray-200 rounded-lg focus:outline-none focus:border-indigo-400 text-lg"
|
|
onkeyup="if(event.key==='Enter')search()">
|
|
</div>
|
|
<button onclick="search()" class="px-6 py-3 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition">
|
|
<i class="ri-search-line mr-2"></i>搜索
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 统计卡片 - 动态生成 -->
|
|
<div class="grid grid-cols-4 gap-4 mb-8" id="statsCards">
|
|
<div class="text-center text-gray-400 py-8">加载中...</div>
|
|
</div>
|
|
|
|
<!-- 分类快捷入口 - 动态生成 -->
|
|
<div class="mb-8">
|
|
<h2 class="text-lg font-semibold text-gray-800 mb-4 flex items-center gap-2">
|
|
<i class="ri-folder-line text-indigo-600"></i>
|
|
参数分类
|
|
</h2>
|
|
<div id="categoryCards" class="grid grid-cols-4 gap-4">
|
|
<div class="text-center text-gray-400 py-8">加载中...</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 热门模型 -->
|
|
<div class="bg-white rounded-xl shadow-sm p-6">
|
|
<h2 class="text-lg font-semibold text-gray-800 mb-4 flex items-center gap-2">
|
|
<i class="ri-cpu-line text-indigo-600"></i>
|
|
热门模型
|
|
</h2>
|
|
<div id="latestModels" class="grid grid-cols-2 gap-4">
|
|
<div class="text-center text-gray-400 py-8">加载中...</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<!-- 页脚 -->
|
|
<footer class="bg-white border-t mt-8 py-6 text-center text-gray-500 text-sm">
|
|
<span id="footerText">ParamHub - 参数百科 | AI模型与硬件参数速查平台</span>
|
|
</footer>
|
|
|
|
<script>
|
|
let categories = [];
|
|
|
|
const colorMap = {
|
|
blue: {bg: 'bg-blue-500', gradient: 'from-blue-500 to-blue-600', icon: 'text-blue-500'},
|
|
green: {bg: 'bg-green-500', gradient: 'from-green-500 to-green-600', icon: 'text-green-500'},
|
|
purple: {bg: 'bg-purple-500', gradient: 'from-purple-500 to-purple-600', icon: 'text-purple-500'},
|
|
orange: {bg: 'bg-orange-500', gradient: 'from-orange-500 to-orange-600', icon: 'text-orange-500'},
|
|
teal: {bg: 'bg-teal-500', gradient: 'from-teal-500 to-teal-600', icon: 'text-teal-500'},
|
|
red: {bg: 'bg-red-500', gradient: 'from-red-500 to-red-600', icon: 'text-red-500'}
|
|
};
|
|
|
|
// 加载导航栏
|
|
function renderNavBar() {
|
|
// 内置页面
|
|
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}`;
|
|
navHtml += `<a href="${href}" class="text-gray-600 hover:text-indigo-600">${cat.name}</a>`;
|
|
});
|
|
|
|
document.getElementById('navLinks').innerHTML = navHtml;
|
|
}
|
|
|
|
// 加载分类和数据统计
|
|
async function loadData() {
|
|
// 并行加载分类、统计、配置
|
|
const [catRes, statsRes, configRes] = await Promise.all([
|
|
fetch('/api/categories'),
|
|
fetch('/api/stats'),
|
|
fetch('/api/config')
|
|
]);
|
|
categories = await catRes.json();
|
|
const stats = await statsRes.json();
|
|
const config = await configRes.json();
|
|
|
|
// 更新网站名称等
|
|
if (config.site_name) {
|
|
document.getElementById('navSiteName').textContent = config.site_name;
|
|
}
|
|
if (config.site_subtitle) {
|
|
document.getElementById('navSiteSubtitle').textContent = config.site_subtitle;
|
|
}
|
|
if (config.site_name && config.site_subtitle) {
|
|
document.getElementById('pageTitle').textContent = `${config.site_name} - ${config.site_subtitle}`;
|
|
}
|
|
if (config.footer_text) {
|
|
document.getElementById('footerText').textContent = config.footer_text;
|
|
}
|
|
if (config.icp_number) {
|
|
document.getElementById('footerText').innerHTML += ` | <a href="https://beian.miit.gov.cn/" target="_blank" class="hover:text-gray-700">${config.icp_number}</a>`;
|
|
}
|
|
|
|
// 渲染导航栏
|
|
renderNavBar();
|
|
|
|
// 渲染统计卡片
|
|
renderStatsCards(stats);
|
|
|
|
// 渲染分类卡片
|
|
renderCategoryCards();
|
|
|
|
// 渲染热门模型
|
|
renderLatestModels(stats.latest_models || []);
|
|
}
|
|
|
|
// 渲染统计卡片
|
|
function renderStatsCards(stats) {
|
|
const statItems = [
|
|
{key: 'models_count', label: 'AI模型', icon: 'ri-robot-line', color: 'blue'},
|
|
{key: 'gpus_count', label: 'GPU显卡', icon: 'ri-cpu-line', color: 'green'},
|
|
{key: 'cpus_count', label: 'CPU处理器', icon: 'ri-cpu-line', color: 'purple'},
|
|
{key: 'knowledge_count', label: '知识条目', icon: 'ri-book-open-line', color: 'teal'}
|
|
];
|
|
|
|
document.getElementById('statsCards').innerHTML = statItems.map(item => {
|
|
const c = colorMap[item.color] || colorMap.blue;
|
|
return `
|
|
<div class="bg-gradient-to-r ${c.gradient} rounded-xl p-5 text-white">
|
|
<div class="flex items-center gap-3">
|
|
<i class="${item.icon} text-3xl opacity-80"></i>
|
|
<div>
|
|
<div class="text-2xl font-bold">${stats[item.key] || 0}</div>
|
|
<div class="text-sm opacity-80">${item.label}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
}
|
|
|
|
// 渲染分类卡片
|
|
function renderCategoryCards() {
|
|
if (categories.length === 0) {
|
|
document.getElementById('categoryCards').innerHTML = '<div class="col-span-4 text-center text-gray-400 py-8">暂无分类</div>';
|
|
return;
|
|
}
|
|
|
|
// 内置页面映射
|
|
const pageMap = {
|
|
'ai-models': '/models',
|
|
'gpus': '/gpus',
|
|
'cpus': '/cpus'
|
|
};
|
|
|
|
document.getElementById('categoryCards').innerHTML = categories.map(cat => {
|
|
const c = colorMap[cat.color] || colorMap.blue;
|
|
const link = pageMap[cat.id] || `/category/${cat.id}`;
|
|
return `
|
|
<a href="${link}" class="bg-white rounded-xl shadow-sm p-5 hover:shadow-md transition group">
|
|
<div class="text-center">
|
|
<div class="w-14 h-14 rounded-xl ${c.bg} bg-opacity-10 flex items-center justify-center mx-auto group-hover:scale-110 transition">
|
|
<i class="${cat.icon} text-3xl ${c.icon}"></i>
|
|
</div>
|
|
<div class="mt-3 font-medium text-gray-800">${cat.name}</div>
|
|
<div class="text-xs text-gray-500 mt-1 truncate">${cat.description || ''}</div>
|
|
</div>
|
|
</a>
|
|
`;
|
|
}).join('');
|
|
}
|
|
|
|
// 渲染热门模型
|
|
function renderLatestModels(models) {
|
|
if (models.length === 0) {
|
|
document.getElementById('latestModels').innerHTML = '<div class="col-span-2 text-center text-gray-400 py-8">暂无数据</div>';
|
|
return;
|
|
}
|
|
|
|
document.getElementById('latestModels').innerHTML = models.map(m => `
|
|
<a href="/models" class="flex items-center gap-4 p-4 rounded-lg hover:bg-gray-50 transition">
|
|
<div class="w-12 h-12 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-600 font-bold">
|
|
${m.name.substring(0, 2)}
|
|
</div>
|
|
<div class="flex-1">
|
|
<div class="font-medium text-gray-800">${m.name}</div>
|
|
<div class="text-sm text-gray-500">${m.organization} | ${m.parameters}B参数</div>
|
|
</div>
|
|
<div class="text-sm text-gray-400">${m.is_open_source ? '开源' : '商业'}</div>
|
|
</a>
|
|
`).join('');
|
|
}
|
|
|
|
// 搜索
|
|
async function search() {
|
|
const keyword = document.getElementById('searchInput').value.trim();
|
|
if (!keyword) return;
|
|
window.location.href = `/models?q=${encodeURIComponent(keyword)}`;
|
|
}
|
|
|
|
// 初始化
|
|
loadData();
|
|
</script>
|
|
</body>
|
|
</html> |