feat(web): restore candidate notice on home for logged-in users

This commit is contained in:
kairee committed 2026-11-01 17:52:03 +08:00
1 parent 0518397492
commit ff88e91640
5 files changed
+39 -12

No files matched your search

+9
View File
@@ -4,6 +4,7 @@ import {
escapeAttr, escapeHtml, formatCount, formatDate, formatDelta,
formatDuration, formatPercent, formatScore,
} from "../format.js";
import { canAccessProtected } from "../session.js";
function statChip(label, value, { href = null, tone = "" } = {}) {
const inner = `<span>${escapeHtml(label)}</span><strong>${value}</strong>`;
@@ -55,6 +56,9 @@ export async function renderHome(root) {
? formatCount(overview.initial_import_count)
: formatCount(overview.added_today);
const activeCount = overview.counts?.active || 0;
const pending = overview.counts?.candidates_pending || 0;
// 候选提示仅对已登录(或未启用鉴权)用户可见,访客不展示运行期信息。
const showCandidates = pending > 0 && canAccessProtected();
root.innerHTML = `<section class="page home-page">
<header class="page-head home-head">
@@ -78,6 +82,11 @@ export async function renderHome(root) {
${statChip("数据日期", escapeHtml(overview.data_date || "—"))}
</div>
${showCandidates ? `<a class="notice-row" href="/candidates">
<strong>${formatCount(pending)} 条候选待确认</strong>
<span>请在 Telegram 中处理 →</span>
</a>` : ""}
<section class="panel">
<div class="section-head">
<h2>最近发布</h2>