新增榜單

This commit is contained in:
Sahik committed 2026-12-02 17:25:56 +08:00
1 parent d2bba07749
commit d4377a47e4
14 files changed
+315 -9

No files matched your search

+54 -1
View File
@@ -159,6 +159,7 @@ function renderSidebar() {
const me = state.me;
$("auth-box").hidden = !!me;
$("me-box").hidden = !me;
$("site-nav").hidden = !!me;
if (!me) return;
$("me-avatar").src = me.avatar_url || DEFAULT_AVATAR;
$("me-name").textContent = me.display_name;
@@ -785,7 +786,7 @@ function bindCheckin() {
// ---------- 畫面切換 ----------
function showView(id) {
for (const v of ["view-checkin", "view-user", "view-upload", "view-images", "view-notices"]) $(v).hidden = v !== id;
for (const v of ["view-checkin", "view-user", "view-upload", "view-images", "view-notices", "view-leaderboard"]) $(v).hidden = v !== id;
if (id !== "view-checkin") { clearInterval(state.resetTimer); closeStage(); state.guestOn = false; }
}
@@ -1075,6 +1076,57 @@ function bindNotices() {
}));
}
// ---------- 全服總榜 ----------
// 一列:名次、大頭貼、名稱與 UID、數值(unit 是 lb.days / lb.clicks)
function lbRow(e, unit) {
const li = document.createElement("li");
li.className = "lb-row";
if (e.rank <= 3) li.classList.add(`top${e.rank}`);
if (state.me?.uid === e.uid) li.classList.add("me");
const rank = document.createElement("span");
rank.className = "lb-rank";
rank.textContent = e.rank;
const avatar = document.createElement("img");
avatar.className = "avatar lb-avatar";
avatar.alt = "";
avatar.width = avatar.height = 40;
avatar.src = e.avatar_url || DEFAULT_AVATAR;
const who = document.createElement("span");
who.className = "lb-who";
const name = document.createElement("a");
name.className = "lb-name";
name.href = `/u/${e.uid_str}`;
name.textContent = e.display_name;
const uid = document.createElement("span");
showUid(uid, e);
who.append(name, uid);
const value = document.createElement("span");
value.className = "lb-value";
value.textContent = t(unit, { n: fmtNum(e.value) });
li.append(rank, avatar, who, value);
return li;
}
function renderLbList(listId, emptyId, items, unit) {
$(listId).replaceChildren(...items.map((e) => lbRow(e, unit)));
$(emptyId).hidden = items.length > 0;
}
async function showLeaderboard() {
showView("view-leaderboard");
document.title = `${t("lb.heading")} · ${SITE_TITLE}`;
try {
const r = await api("GET", "/api/leaderboard");
$("lb-total-checkins").textContent = fmtNum(r.total_checkins);
$("lb-total-clicks").textContent = fmtNum(r.total_clicks);
renderLbList("lb-days", "lb-days-empty", r.by_days, "lb.days");
renderLbList("lb-clicks", "lb-clicks-empty", r.by_clicks, "lb.clicks");
} catch (e) {
toast(errText(e));
}
}
// ---------- 個人頁 ----------
async function showUser(uid) {
@@ -1243,6 +1295,7 @@ async function route() {
if (location.pathname === "/upload") return showUpload();
if (location.pathname === "/images" || location.pathname === "/review") return showImages();
if (location.pathname === "/notices") return showNotices();
if (location.pathname === "/leaderboard") return showLeaderboard();
return showCheckin();
}
+10 -1
View File
@@ -144,5 +144,14 @@
"source.label": "Source (optional)",
"source.placeholder": "e.g. x@sthkm3",
"err.source_too_long": "Source can be up to 40 characters",
"err.unsupported_format": "Only JPG, PNG and WEBP are supported (no GIF)"
"err.unsupported_format": "Only JPG, PNG and WEBP are supported (no GIF)",
"nav.leaderboard": "Leaderboard",
"lb.heading": "Leaderboard",
"lb.total_checkins": "Total check-ins",
"lb.total_clicks": "Total squeaks",
"lb.by_days": "Most check-ins",
"lb.by_clicks": "Most squeaks",
"lb.days": "{n} days",
"lb.clicks": "{n} squeaks",
"lb.empty": "No one on the board yet"
}
+10 -1
View File
@@ -144,5 +144,14 @@
"source.label": "出典(任意)",
"source.placeholder": "例:x@sthkm3",
"err.source_too_long": "出典は 40 文字までです",
"err.unsupported_format": "JPG・PNG・WEBP のみ対応しています(GIF は不可)"
"err.unsupported_format": "JPG・PNG・WEBP のみ対応しています(GIF は不可)",
"nav.leaderboard": "全体ランキング",
"lb.heading": "全体ランキング",
"lb.total_checkins": "合計チェックイン回数",
"lb.total_clicks": "合計チューチュー回数",
"lb.by_days": "チェックイン回数ランキング",
"lb.by_clicks": "チューチュー回数ランキング",
"lb.days": "{n} 日",
"lb.clicks": "{n} 回",
"lb.empty": "まだ誰もランクインしていません"
}
+10 -1
View File
@@ -144,5 +144,14 @@
"source.label": "출처 (선택)",
"source.placeholder": "예: x@sthkm3",
"err.source_too_long": "출처는 40자까지예요",
"err.unsupported_format": "JPG, PNG, WEBP만 지원해요 (GIF 불가)"
"err.unsupported_format": "JPG, PNG, WEBP만 지원해요 (GIF 불가)",
"nav.leaderboard": "전체 랭킹",
"lb.heading": "전체 랭킹",
"lb.total_checkins": "총 출석 횟수",
"lb.total_clicks": "총 찍찍 횟수",
"lb.by_days": "출석 횟수 랭킹",
"lb.by_clicks": "찍찍 횟수 랭킹",
"lb.days": "{n}일",
"lb.clicks": "{n}번",
"lb.empty": "아직 랭킹에 오른 사람이 없어요"
}
+10 -1
View File
@@ -144,5 +144,14 @@
"source.label": "出处(选填)",
"source.placeholder": "例如 x@sthkm3",
"err.source_too_long": "出处最多 40 个字",
"err.unsupported_format": "只支持 JPG、PNG、WEBP(不收 GIF)"
"err.unsupported_format": "只支持 JPG、PNG、WEBP(不收 GIF)",
"nav.leaderboard": "全服总榜",
"lb.heading": "全服总榜",
"lb.total_checkins": "总签到次数",
"lb.total_clicks": "总吱吱次数",
"lb.by_days": "签到次数排行榜",
"lb.by_clicks": "吱吱次数排行榜",
"lb.days": "{n} 天",
"lb.clicks": "{n} 次",
"lb.empty": "还没有人上榜"
}
+10 -1
View File
@@ -144,5 +144,14 @@
"source.label": "出處(選填)",
"source.placeholder": "例如 x@sthkm3",
"err.source_too_long": "出處最多 40 個字",
"err.unsupported_format": "只支援 JPG、PNG、WEBP(不收 GIF)"
"err.unsupported_format": "只支援 JPG、PNG、WEBP(不收 GIF)",
"nav.leaderboard": "全服總榜",
"lb.heading": "全服總榜",
"lb.total_checkins": "總簽到次數",
"lb.total_clicks": "總吱吱次數",
"lb.by_days": "簽到次數排行榜",
"lb.by_clicks": "吱吱次數排行榜",
"lb.days": "{n} 天",
"lb.clicks": "{n} 次",
"lb.empty": "還沒有人上榜"
}
+20
View File
@@ -59,10 +59,16 @@
<a id="upload-link" href="/upload" data-i18n="nav.upload"></a>
<a id="review-link" href="/images" hidden></a>
<a id="notices-link" href="/notices" hidden></a>
<a href="/leaderboard" data-i18n="nav.leaderboard"></a>
<button type="button" class="link" id="logout" data-i18n="auth.logout"></button>
</nav>
</section>
<!-- 沒登入時的選單(登入後全服總榜在上面個人選單的登出上方) -->
<nav class="me-nav site-nav" id="site-nav">
<a href="/leaderboard" data-i18n="nav.leaderboard"></a>
</nav>
<div class="sidebar-foot">
<label class="lang"><span data-i18n="lang.label"></span>
<select id="lang">
@@ -189,6 +195,20 @@
<button type="button" id="notices-more" data-i18n="notices.more" hidden></button>
</section>
<section id="view-leaderboard" hidden>
<h1 data-i18n="lb.heading"></h1>
<div class="lb-totals">
<div class="lb-total"><b id="lb-total-checkins">–</b><span data-i18n="lb.total_checkins"></span></div>
<div class="lb-total"><b id="lb-total-clicks">–</b><span data-i18n="lb.total_clicks"></span></div>
</div>
<h2 data-i18n="lb.by_days"></h2>
<ol class="lb-list" id="lb-days"></ol>
<p class="hint" id="lb-days-empty" data-i18n="lb.empty" hidden></p>
<h2 data-i18n="lb.by_clicks"></h2>
<ol class="lb-list" id="lb-clicks"></ol>
<p class="hint" id="lb-clicks-empty" data-i18n="lb.empty" hidden></p>
</section>
<section id="view-user" hidden>
<div id="user-card" class="profile" hidden>
<img id="user-avatar" class="avatar large" alt="" width="160" height="160">
+29
View File
@@ -157,6 +157,35 @@ button.link:disabled { color: var(--muted); }
.notice-list li.unread { border-color: var(--accent); }
.flag-box { width: 100%; margin-top: 12px; padding: 12px 16px; border: 1px solid var(--error); border-radius: var(--radius); }
/* 全服總榜 */
.site-nav { margin-top: 0; }
#view-leaderboard { width: 100%; max-width: 560px; }
#view-leaderboard h1 { font-size: 24px; margin: 0 0 8px; }
#view-leaderboard h2 { font-size: 18px; margin: 28px 0 4px; }
.lb-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 8px; }
.lb-total {
display: flex; flex-direction: column; align-items: center; gap: 4px;
padding: 20px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
text-align: center;
}
.lb-total b { font-size: clamp(26px, 7vw, 40px); color: var(--accent); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.1; }
.lb-total span { font-size: 14px; color: var(--muted); }
.lb-list { list-style: none; margin: 8px 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lb-row {
display: flex; align-items: center; gap: 12px;
padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.lb-row.me { border-color: var(--accent); }
.lb-rank { flex: 0 0 2em; text-align: center; font-size: 18px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-row.top1 .lb-rank { color: #ffd166; }
.lb-row.top2 .lb-rank { color: #d9d9d9; }
.lb-row.top3 .lb-rank { color: #e0a070; }
.lb-avatar { width: 40px; height: 40px; flex: 0 0 auto; }
.lb-who { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.lb-name { font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.lb-who .uid, .lb-who .title-badge { font-size: 12px; padding: 1px 8px; margin-top: 0; }
.lb-value { flex: 0 0 auto; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 手機:提示可以安裝到桌面 */
.install-hint {
width: 100%;