feat(web): clickable home stats, drop recent-ingest panel, rename watch link
This commit is contained in:
1 parent
bfde231b90
commit
1ed3746f4b
6 files changed
+26
-31
No files matched your search
@@ -3,14 +3,16 @@ import {
|
||||
emptyState, cover, sectionHeader, videoCard,
|
||||
} from "../components.js";
|
||||
import {
|
||||
escapeHtml, formatCount, formatDate, formatDelta, formatDateTime,
|
||||
escapeAttr, escapeHtml, formatCount, formatDate, formatDelta, formatDateTime,
|
||||
formatPercent, formatScore,
|
||||
} from "../format.js";
|
||||
|
||||
function statChip(label, value, tone = "") {
|
||||
return `<div class="live-chip ${tone}">
|
||||
<span>${escapeHtml(label)}</span><strong>${value}</strong>
|
||||
</div>`;
|
||||
function statChip(label, value, { href = null, tone = "" } = {}) {
|
||||
const inner = `<span>${escapeHtml(label)}</span><strong>${value}</strong>`;
|
||||
if (href) {
|
||||
return `<a class="live-chip ${tone}" href="${escapeAttr(href)}">${inner}</a>`;
|
||||
}
|
||||
return `<div class="live-chip ${tone}">${inner}</div>`;
|
||||
}
|
||||
|
||||
function heatStrip(items) {
|
||||
@@ -45,9 +47,8 @@ function capacity(folders) {
|
||||
}
|
||||
|
||||
export async function renderHome(root) {
|
||||
const [overview, added, published, heat, growth] = await Promise.all([
|
||||
const [overview, published, heat, growth] = await Promise.all([
|
||||
api("/api/overview"),
|
||||
api("/api/videos", { sort: "added", within_days: 7, limit: 5 }),
|
||||
api("/api/videos", { sort: "published", within_days: 14, limit: 5 }),
|
||||
api("/api/videos", { sort: "heat", limit: 5 }),
|
||||
api("/api/videos", { sort: "growth", growth_days: 7, limit: 3 }),
|
||||
@@ -60,10 +61,6 @@ export async function renderHome(root) {
|
||||
? formatCount(overview.initial_import_count)
|
||||
: formatCount(overview.added_today);
|
||||
const health = overview.snapshot_health || { total: 0, ok: 0, failed: 0 };
|
||||
const addedNote = firstDay
|
||||
? `<p class="section-note">首次导入共 ${formatCount(overview.initial_import_count)} 条,
|
||||
按发布时间倒序展示。后续每日增量从下一次快照开始。</p>`
|
||||
: `<p class="section-note">按入库时间排序,展示最近 7 天新收录的视频。</p>`;
|
||||
|
||||
root.innerHTML = `<section class="page home-page">
|
||||
<header class="page-head home-head">
|
||||
@@ -76,10 +73,18 @@ export async function renderHome(root) {
|
||||
</header>
|
||||
|
||||
<div class="live-strip">
|
||||
${statChip(firstDay ? "首次导入" : "今日入库", escapeHtml(addedLabel), "accent")}
|
||||
${statChip("播放增量", overview.view_delta_available ? formatDelta(overview.view_delta) : "—")}
|
||||
${statChip("粉丝日增", fans?.delta_1d === null || fans?.delta_1d === undefined ? "—" : formatDelta(fans.delta_1d))}
|
||||
${statChip("待确认候选", formatCount(pending), pending ? "warning" : "")}
|
||||
${statChip(firstDay ? "首次导入" : "今日入库", escapeHtml(addedLabel), {
|
||||
href: "/videos?sort=added&within_days=7", tone: "accent",
|
||||
})}
|
||||
${statChip("播放增量", overview.view_delta_available ? formatDelta(overview.view_delta) : "—", {
|
||||
href: "/videos?sort=growth&growth_days=1",
|
||||
})}
|
||||
${statChip("粉丝日增", fans?.delta_1d === null || fans?.delta_1d === undefined ? "—" : formatDelta(fans.delta_1d), {
|
||||
href: "/fans",
|
||||
})}
|
||||
${statChip("待确认候选", formatCount(pending), {
|
||||
href: "/candidates", tone: pending ? "warning" : "",
|
||||
})}
|
||||
</div>
|
||||
|
||||
${pending ? `<a class="notice-row" href="/candidates">
|
||||
@@ -87,18 +92,6 @@ export async function renderHome(root) {
|
||||
<span>请在 Telegram 中处理 →</span>
|
||||
</a>` : ""}
|
||||
|
||||
<section class="panel">
|
||||
<div class="section-head">
|
||||
<h2>最新入库</h2>
|
||||
<a class="text-link" href="/videos?sort=added&within_days=7">查看全部</a>
|
||||
</div>
|
||||
${addedNote}
|
||||
<div class="video-list">
|
||||
${added.items.length ? added.items.map((item) => videoCard(item)).join("")
|
||||
: emptyState("最近 7 天没有新入库视频", "搜索发现确认或 Telegram 私聊手动入库后会出现在这里。")}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<div class="section-head">
|
||||
<h2>最近发布</h2>
|
||||
|
||||
@@ -48,7 +48,7 @@ export async function renderVideo(root, { params, query }) {
|
||||
<header class="page-head">
|
||||
<a class="back-link" href="/videos">← 返回视频榜</a>
|
||||
<div class="head-actions">
|
||||
${detail.url ? `<a class="button ghost" href="${escapeAttr(detail.url)}" target="_blank" rel="noreferrer">打开 B 站</a>` : ""}
|
||||
${detail.url ? `<a class="button ghost" href="${escapeAttr(detail.url)}" target="_blank" rel="noreferrer">B 站观看</a>` : ""}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
Reference in new issue
Block a user