(function () { fetch("../notices.json?v=" + Math.floor(Date.now() / 300000), { cache: "no-store" }) .then(function (response) { if (!response.ok) { throw new Error("notice source unavailable"); } return response.json(); }) .then(function (payload) { var notices = Array.isArray(payload) ? payload : payload.notices; var notice = Array.isArray(notices) && notices.find(function (item) { return item && item.enabled !== false; }); if (notice) { renderNotice(notice); } }) .catch(function () {}); function renderNotice(notice) { setText("noticeTitle", notice.title || "重要通知"); setText("noticeSummary", notice.message || ""); setText("noticeBadge", notice.badge || "通知"); setText("noticeLevel", String(notice.level || "info").toUpperCase()); setText("articleTitle", notice.title || "重要通知"); setText("articleMessage", notice.message || ""); setText("noticeDate", formatDate(notice.startsAt) || "未设置开始时间"); setText("noticeWindow", formatWindow(notice.startsAt, notice.endsAt)); } function setText(id, text) { var node = document.getElementById(id); if (node) { node.textContent = text; } } function formatDate(value) { if (!value) { return ""; } var date = new Date(value); if (Number.isNaN(date.getTime())) { return ""; } return date.toLocaleDateString("zh-CN", { year: "numeric", month: "2-digit", day: "2-digit" }); } function formatWindow(start, end) { var startText = formatDate(start); var endText = formatDate(end); if (startText && endText) { return startText + " 至 " + endText; } if (startText) { return startText + " 起生效"; } return "长期有效"; } })();