总览页增加北京时间实时显示。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-03 03:26:45 +08:00
parent e62e0579de
commit 6d750d0e3f
3 changed files with 91 additions and 14 deletions
+30
View File
@@ -98,6 +98,36 @@ body.page-login .main {
font-weight: 600;
letter-spacing: 0.04em;
}
.overview-bj-clock {
margin-left: auto;
display: inline-flex;
align-items: baseline;
gap: 8px;
padding: 6px 12px;
border-radius: 999px;
border: 1px solid rgba(56, 189, 248, 0.22);
background: rgba(8, 14, 24, 0.72);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.overview-bj-label {
font-size: 0.72rem;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--accent);
font-weight: 600;
}
.overview-bj-time {
font-family: var(--font-display);
font-size: 0.95rem;
font-weight: 600;
letter-spacing: 0.04em;
color: var(--text);
font-variant-numeric: tabular-nums;
}
@media (max-width: 720px) {
.page-head { flex-wrap: wrap; }
.overview-bj-clock { margin-left: 0; order: 3; width: 100%; justify-content: center; }
}
.muted { color: var(--muted); font-size: 0.9rem; }
.flash {
background: rgba(14, 165, 233, 0.12);
+43
View File
@@ -331,9 +331,52 @@
}
}
function formatBeijingNow() {
try {
return new Intl.DateTimeFormat("zh-CN", {
timeZone: "Asia/Shanghai",
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false,
}).format(new Date());
} catch (e) {
const d = new Date();
const utc = d.getTime() + d.getTimezoneOffset() * 60000;
const bj = new Date(utc + 8 * 3600000);
const p = function (n) {
return String(n).padStart(2, "0");
};
return (
bj.getFullYear() +
"/" +
p(bj.getMonth() + 1) +
"/" +
p(bj.getDate()) +
" " +
p(bj.getHours()) +
":" +
p(bj.getMinutes()) +
":" +
p(bj.getSeconds())
);
}
}
function tickBeijingClock() {
const el = document.getElementById("overview-bj-time");
if (!el) return;
el.textContent = formatBeijingNow();
}
function boot() {
const btn = document.getElementById("btn-refresh");
if (btn) btn.addEventListener("click", refresh);
tickBeijingClock();
setInterval(tickBeijingClock, 1000);
refresh();
setInterval(refresh, 10000);
}