initial: blog-app snapshot
This commit is contained in:
19
static/js/components/stats-card.js
Normal file
19
static/js/components/stats-card.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/* Stats cards component — 首页 #statsRow 四项统计数字.
|
||||
* 复用 index.html 现有的 id (statProjects/statReleases/statIssues/statStars),
|
||||
* 与模板中预置的占位卡片结构对应, 只填数字不重排 DOM.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {{total_projects:number, total_releases:number, total_issues:number, total_stars:number}} stats
|
||||
* @param {HTMLElement|Document} [root] - 作用域根节点, 默认 document
|
||||
*/
|
||||
export function renderStatsCards(stats, root = document) {
|
||||
const set = (id, value) => {
|
||||
const el = root.getElementById ? root.getElementById(id) : root.querySelector(`#${id}`);
|
||||
if (el) el.textContent = value;
|
||||
};
|
||||
set("statProjects", stats.total_projects);
|
||||
set("statReleases", stats.total_releases);
|
||||
set("statIssues", stats.total_issues);
|
||||
set("statStars", stats.total_stars);
|
||||
}
|
||||
Reference in New Issue
Block a user