/* 首页逻辑: 统计卡片 + 项目 dashboard. * renderProjectCard 由模板内联 module 注入 (templates/index.html 直接引用组件, * 保持组件对模板可见, 便于逐页切换验证). */ import { fetchJson } from "../utils.js"; import { renderStatsCards } from "../components/stats-card.js"; export function initIndexPage(renderProjectCard) { async function loadStats() { try { const stats = await fetchJson("/api/stats"); renderStatsCards(stats); } catch (err) { console.error("加载统计失败:", err); } } async function loadProjects() { const container = document.getElementById("projectCards"); try { const projects = await fetchJson("/api/projects"); if (!projects.length) { container.innerHTML = '