This commit is contained in:
Sahik committed 2026-11-22 18:38:53 +08:00
commit 21851bf8c5
61 files changed
+5260

No files matched your search

+931
View File
@@ -0,0 +1,931 @@
// 吱鼯計畫前端:純 JS,沒有框架
const LANGS = ["zh-TW", "zh-CN", "ja", "ko", "en"];
const HTML_LANG = { "zh-TW": "zh-Hant-TW", "zh-CN": "zh-Hans-CN", ja: "ja", ko: "ko", en: "en" };
const DEFAULT_AVATAR = "/assets/avatar.svg";
const $ = (id) => document.getElementById(id);
const HOME_TITLE = document.title; // 「吱鼯計畫 — 你今天吱吱了嗎」,伺服器會依 BETA 開關加上 (Beta)
const SITE_TITLE = HOME_TITLE.split(" — ")[0]; // 其他頁面的標題只接站名
// 伺服器填入的檔案版本,語言檔網址也帶上,改版後不會拿到快取的舊檔
const ASSET_V = document.querySelector('meta[name="asset-version"]')?.content || "";
const VIDEO_MAX_MS = 4000; // 吱吱影片約 1.6 秒;ended 沒觸發(例如播放失敗)時的保險時間
const ZHI_GAP_MS = 1100; // 伺服器一個帳號一秒只收一下;補送沒送成功的次數時,每下隔這麼久
const SUBMIT_MAX_BYTES = 5 * 1024 * 1024;
const state = {
lang: "zh-TW",
dict: {},
me: null,
today: null,
email: "",
cardBust: Date.now(),
resendTimer: null,
resetTimer: null,
zhiMode: null, // null = 沒開 / "checkin" = 簽到那一下 / "more" = 繼續吱吱
zhiBusy: false, // 影片播放中:不接受點擊(簽到和繼續吱吱都一樣)
zhiSkipped: false, // 今天還沒簽到,但使用者按了「等等再吱」
zhiPending: 0, // 還沒送到伺服器的點擊次數
zhiTimer: null,
zhiAuto: false, // 全自動吱吱開著:播完自動接下一次
zhiAutoTimer: null,
zhiLastAt: 0, // 上一次繼續吱吱的時間
zhiPlay: 0, // 第幾次播放;離開再進來時,舊的那次播完不能動到新的
zhiFlush: null, // 正在送次數的 Promise(離開時等它送完)
};
// ---------- i18n ----------
function detectLang() {
const saved = localStorage.getItem("lang");
if (LANGS.includes(saved)) return saved;
for (const raw of navigator.languages || [navigator.language || ""]) {
const l = raw.toLowerCase();
if (/^zh-(tw|hk|mo|hant)/.test(l)) return "zh-TW";
if (l.startsWith("zh")) return "zh-CN";
if (l.startsWith("ja")) return "ja";
if (l.startsWith("ko")) return "ko";
if (l.startsWith("en")) return "en";
}
return "en";
}
async function loadLang(lang) {
const res = await fetch(`/assets/i18n/${lang}.json?v=${ASSET_V}`);
state.dict = await res.json();
state.lang = lang;
localStorage.setItem("lang", lang);
document.documentElement.lang = HTML_LANG[lang];
$("lang").value = lang;
document.querySelectorAll("[data-i18n]").forEach((el) => { el.textContent = t(el.dataset.i18n); });
document.querySelectorAll("[data-i18n-aria]").forEach((el) => {
el.setAttribute("aria-label", t(el.dataset.i18nAria));
});
}
function t(key, vars = {}) {
let s = state.dict[key] ?? key;
for (const [k, v] of Object.entries(vars)) s = s.replaceAll(`{${k}}`, v);
return s;
}
// ---------- API ----------
class ApiError extends Error {
constructor(code, status) { super(code); this.code = code; this.status = status; }
}
async function api(method, path, body) {
const opt = { method, headers: { "X-ZHIWU": "1" }, credentials: "same-origin" };
if (body instanceof FormData) {
opt.body = body;
} else if (body !== undefined) {
opt.headers["Content-Type"] = "application/json";
opt.body = JSON.stringify(body);
}
let res;
try {
res = await fetch(path, opt);
} catch {
throw new ApiError("network", 0);
}
const data = await res.json().catch(() => ({}));
if (!res.ok) throw new ApiError(typeof data.detail === "string" ? data.detail : "unknown", res.status);
return data;
}
function errText(e) {
const key = `err.${e?.code || "unknown"}`;
return key in state.dict ? t(key) : t("err.unknown");
}
function showError(el, e) {
if (e) { el.textContent = errText(e); el.hidden = false; } else { el.hidden = true; }
}
function toast(msg) {
const el = $("toast");
el.textContent = msg;
el.hidden = false;
clearTimeout(toast.timer);
toast.timer = setTimeout(() => { el.hidden = true; }, 2500);
}
// ---------- 側邊欄:登入 / 個人資訊 ----------
// 底色上要用深色字還是白字(和 server/app/titles.py 的 text_on() 同一條公式)
function textOn(hex) {
const [r, g, b] = [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16));
return (r * 299 + g * 587 + b * 114) / 1000 >= 150 ? "#2a1400" : "#ffffff";
}
// UID 與稱號。管理員指定的顏色(title_color)優先,其次是預設的特殊序號(uid_tier,目前只有管理員)
function showUid(el, user) {
const uid = document.createElement("span");
uid.textContent = `UID ${user.uid_str}`;
uid.className = "uid";
const parts = [uid];
let title = null;
if (user.title) {
title = document.createElement("span");
title.textContent = user.title;
title.className = "title-badge";
parts.push(title);
}
if (user.title_color) {
for (const p of parts) {
p.classList.add("badge");
p.style.background = user.title_color;
p.style.color = textOn(user.title_color);
}
} else if (user.uid_tier) {
for (const p of parts) p.classList.add("badge", `tier-${user.uid_tier}`);
}
el.className = "uid-wrap";
el.replaceChildren(...parts);
}
function renderSidebar() {
const me = state.me;
$("auth-box").hidden = !!me;
$("me-box").hidden = !me;
if (!me) return;
$("me-avatar").src = me.avatar_url || DEFAULT_AVATAR;
$("me-name").textContent = me.display_name;
showUid($("me-uid"), me);
$("me-link").href = `/u/${me.uid_str}`;
$("review-link").hidden = !me.is_admin;
if (me.is_admin) $("review-link").textContent = t("nav.review", { n: me.pending_reviews ?? 0 });
}
function showCodeStep(show) {
$("email-form").hidden = show;
$("code-form").hidden = !show;
showError($("auth-error"), null);
if (show) {
$("code-sent-msg").textContent = t("auth.sent", { email: state.email });
$("code").value = "";
$("code").focus();
}
}
function startResendCountdown(seconds) {
clearInterval(state.resendTimer);
const btn = $("resend");
let left = seconds;
const tick = () => {
btn.disabled = left > 0;
btn.textContent = left > 0 ? t("auth.resend_wait", { s: left }) : t("auth.resend");
if (left-- <= 0) clearInterval(state.resendTimer);
};
tick();
state.resendTimer = setInterval(tick, 1000);
}
async function sendCode() {
const r = await api("POST", "/api/auth/request-code", { email: state.email, lang: state.lang });
showCodeStep(true);
startResendCountdown(r.resend_in);
}
async function withBusy(button, fn) {
button.disabled = true;
try { await fn(); } finally { button.disabled = false; }
}
function bindAuth() {
$("email-form").addEventListener("submit", (ev) => {
ev.preventDefault();
state.email = $("email").value.trim();
withBusy(ev.submitter || $("email-form").querySelector("button"), async () => {
try { await sendCode(); } catch (e) { showError($("auth-error"), e); }
});
});
$("code-form").addEventListener("submit", (ev) => {
ev.preventDefault();
const code = $("code").value.replace(/\D/g, "");
withBusy(ev.submitter || $("code-form").querySelector("button[type=submit]"), async () => {
try {
const r = await api("POST", "/api/auth/verify", { email: state.email, code, lang: state.lang });
state.me = r.user;
clearInterval(state.resendTimer);
showCodeStep(false);
$("email").value = "";
if (r.user.lang !== state.lang) await loadLang(r.user.lang);
renderSidebar();
closeMenu();
await route();
} catch (e) {
showError($("auth-error"), e);
if (e.code === "expired" || e.code === "not_requested") $("code").value = "";
}
});
});
$("resend").addEventListener("click", async () => {
try { await sendCode(); } catch (e) { showError($("auth-error"), e); }
});
$("change-email").addEventListener("click", () => {
clearInterval(state.resendTimer);
showCodeStep(false);
$("email").focus();
});
$("logout").addEventListener("click", async () => {
try { await api("POST", "/api/auth/logout"); } catch { /* 已經登出也沒關係 */ }
state.me = null;
state.today = null;
state.zhiSkipped = false;
renderSidebar();
await route();
});
$("guest-login").addEventListener("click", () => {
openMenu();
$("email").focus();
});
}
// ---------- 簽到 ----------
function showCheckinPart(part) {
for (const id of ["checkin-guest", "checkin-ready", "checkin-done"]) $(id).hidden = id !== part;
}
function statsText(d) {
return [
t("checkin.total", { n: d.total_days }),
t("checkin.streak", { n: d.streak }),
t("checkin.clicks", { n: fmtNum(d.clicks ?? 0) }),
].join(" · ");
}
function fmtNum(n) { return Number(n).toLocaleString("en-US"); }
// 小卡上有吱吱次數,網址帶 c=<次數>,次數變了才會重新下載
function cardSrc(d) { return `${d.card_url}?v=${state.cardBust}&c=${d.clicks}`; }
function renderToday(justChecked) {
const d = state.today;
if (!d.checked_in) {
showCheckinPart("checkin-ready");
$("ready-stats").textContent = d.total_days || d.clicks ? statsText(d) : "";
// 還沒簽到:直接蓋上全螢幕的吱吱畫面(除非使用者剛剛選了等等再吱)
if (!state.zhiSkipped && state.zhiMode !== "checkin") openStage("checkin");
} else {
if (state.zhiMode === "checkin") closeStage(); // 例如在另一個分頁簽到了
showCheckinPart("checkin-done");
$("checkin-msg").textContent = justChecked ? t("checkin.success") : t("checkin.done_today");
const src = cardSrc(d);
if ($("card-img").getAttribute("src") !== src) $("card-img").src = src;
$("download-btn").href = src;
$("download-btn").setAttribute("download", `zhiwu-${d.day}.png`);
$("done-stats").textContent = statsText(d);
}
startResetCountdown();
}
function fmtDuration(ms) {
const s = Math.max(0, Math.floor(ms / 1000));
const pad = (n) => String(n).padStart(2, "0");
return `${pad(Math.floor(s / 3600))}:${pad(Math.floor((s % 3600) / 60))}:${pad(s % 60)}`;
}
function startResetCountdown() {
clearInterval(state.resetTimer);
const el = $("next-reset");
if (!state.today) { el.hidden = true; return; }
const target = Date.parse(state.today.next_reset);
// 伺服器以台灣時間 04:00 換日,這裡換算成裝置的當地時間顯示
const when = new Intl.DateTimeFormat(HTML_LANG[state.lang], {
month: "numeric", day: "numeric", hour: "2-digit", minute: "2-digit", hourCycle: "h23",
}).format(new Date(target));
el.hidden = false;
const tick = async () => {
const left = target - Date.now();
el.textContent = t("checkin.next", { time: when, t: fmtDuration(left) });
if (left <= 0) {
clearInterval(state.resetTimer);
if (state.zhiMode === "more") return; // 正在繼續吱吱就不打斷,回到小卡時會重新整理
state.zhiSkipped = false;
await refreshToday(); // 換日了
}
};
tick();
state.resetTimer = setInterval(tick, 1000);
}
async function refreshToday() {
try {
state.today = await api("GET", "/api/checkin/today");
renderToday(false);
} catch (e) {
if (e.status === 401) { state.me = null; renderSidebar(); showGuest(); } else toast(errText(e));
}
}
function showGuest() {
clearInterval(state.resetTimer);
$("next-reset").hidden = true;
closeStage();
showCheckinPart("checkin-guest");
}
async function showCheckin() {
showView("view-checkin");
if (!state.me) return showGuest();
await refreshToday();
}
async function shareCard() {
const d = state.today;
const text = `${d.share_text} ${d.share_url}`;
try {
const blob = await fetch($("card-img").src).then((r) => r.blob());
const file = new File([blob], `zhiwu-${d.day}.png`, { type: "image/png" });
if (navigator.canShare && navigator.canShare({ files: [file] })) {
await navigator.share({ files: [file], text });
return;
}
if (navigator.share) {
await navigator.share({ text: d.share_text, url: d.share_url });
return;
}
} catch (e) {
if (e.name === "AbortError") return; // 使用者自己取消
}
try {
await navigator.clipboard.writeText(text);
toast(t("share.copied"));
} catch {
window.prompt("", text);
}
}
// 從點擊的位置噴出粒子(橘色系,夾幾個「吱」字)
function burst(x, y, count = 28) {
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
const spread = Math.min(window.innerWidth, window.innerHeight) * 0.28;
const colors = ["#ff8a1f", "#ffd166", "#ffb347", "#fff6ea", "#ff6a00"];
for (let i = 0; i < count; i++) {
const p = document.createElement("span");
const word = i % 5 === 0;
p.className = word ? "particle digit" : "particle";
if (word) p.textContent = "吱";
const angle = (i / count) * Math.PI * 2 + Math.random() * 0.5;
const dist = spread * 0.5 + Math.random() * spread;
const size = word ? 22 + Math.random() * 18 : 6 + Math.random() * 9;
p.style.cssText = [
`--x:${x}px`, `--y:${y}px`,
`--dx:${(Math.cos(angle) * dist).toFixed(1)}px`, `--dy:${(Math.sin(angle) * dist).toFixed(1)}px`,
`--s:${size.toFixed(1)}px`, `--c:${colors[i % colors.length]}`,
`--r:${Math.round(Math.random() * 360 - 180)}deg`, `--d:${(0.7 + Math.random() * 0.4).toFixed(2)}s`,
].join(";");
p.addEventListener("animationend", () => p.remove());
document.body.appendChild(p);
}
}
// 先把小卡下載好,切換畫面時才不會看到空白
function preloadImage(src, maxMs = 6000) {
return new Promise((resolve) => {
const img = new Image();
const timer = setTimeout(resolve, maxMs);
img.onload = img.onerror = () => { clearTimeout(timer); resolve(); };
img.src = src;
});
}
// ---------- 全螢幕吱吱 ----------
// 還沒點擊時停在影片第一幀,中間寫「點擊吱吱」。
// 簽到模式(checkin):點一下 → 有聲播到完 → 送出簽到 → 亮出小卡
// 繼續吱吱(more):點一下播一次、吱吱次數 +1,播完才能再點(播放中點了沒反應),不會跳去小卡
// 中下方的「全自動吱吱」打開後,播完會自動接著吱下一次,直到關掉或回到小卡
// 影片回到第一幀並暫停,重新顯示「點擊吱吱」
function resetVideo() {
const video = $("zhi-video");
video.pause();
try { video.currentTime = 0; } catch { /* 還沒載入 metadata */ }
$("zhi-stage").classList.remove("playing");
}
// 從頭播放(一定要在點擊事件裡呼叫,瀏覽器才允許有聲播放)
function playVideo() {
const video = $("zhi-video");
$("zhi-stage").classList.add("playing");
try { video.currentTime = 0; } catch { /* 還沒載入 metadata */ }
video.muted = false;
const p = video.play();
if (p) p.catch(() => { /* 真的不能播就只剩粒子 */ });
}
// 等影片播完(或保險時間到)
function waitVideoEnd() {
const video = $("zhi-video");
return new Promise((resolve) => {
const done = () => { clearTimeout(timer); video.removeEventListener("ended", done); resolve(); };
const timer = setTimeout(done, VIDEO_MAX_MS);
video.addEventListener("ended", done);
});
}
function showZhiCount(bump) {
const el = $("zhi-count");
el.textContent = t("zhi.count", { n: fmtNum(state.today?.clicks ?? 0) });
if (bump) { el.classList.remove("bump"); void el.offsetWidth; el.classList.add("bump"); }
}
function openStage(mode) {
state.zhiMode = mode;
state.zhiBusy = false;
state.zhiPlay++;
resetVideo();
$("zhi-exit").textContent = t(mode === "more" ? "zhi.back" : "zhi.later");
$("zhi-exit").disabled = false;
$("zhi-count").hidden = mode !== "more";
$("zhi-auto").hidden = mode !== "more";
setZhiAuto(false);
if (mode === "more") showZhiCount(false);
$("zhi-stage").hidden = false;
document.body.classList.add("zhi-on");
closeMenu();
}
function closeStage() {
if (!state.zhiMode) return;
setZhiAuto(false);
state.zhiMode = null;
state.zhiBusy = false;
resetVideo();
$("zhi-stage").hidden = true;
document.body.classList.remove("zhi-on");
}
// 簽到:播影片、噴粒子,同時送出簽到;影片播完而且小卡下載好才亮出小卡
async function zhiCheckin(x, y) {
if (state.zhiBusy) return;
state.zhiBusy = true;
$("zhi-exit").disabled = true;
playVideo();
burst(x, y);
const ended = waitVideoEnd();
try {
const today = await api("POST", "/api/checkin");
await Promise.all([ended, today.card_url ? preloadImage(cardSrc(today)) : null]);
state.today = today;
state.zhiSkipped = false;
closeStage();
renderToday(!today.already);
loadMe();
} catch (e) {
if (state.zhiMode === "checkin") {
state.zhiBusy = false;
$("zhi-exit").disabled = false;
resetVideo();
}
toast(errText(e));
}
}
// 繼續吱吱:播放中再點沒有反應;播完回到第一幀才能點下一次
function zhiMore(x, y) {
if (state.zhiBusy) return;
// 一個帳號一秒只能吱一次(伺服器也會擋)。影片比 1 秒長,只有離開再馬上進來時會遇到
if (Date.now() - state.zhiLastAt < ZHI_GAP_MS) return;
state.zhiLastAt = Date.now();
state.zhiBusy = true;
const play = ++state.zhiPlay;
playVideo();
burst(x, y, 12);
state.zhiPending++;
state.today.clicks++;
showZhiCount(true);
flushZhi();
waitVideoEnd().then(() => {
if (state.zhiMode !== "more" || state.zhiPlay !== play) return; // 播到一半按了回到小卡(或離開後又進來)
resetVideo();
state.zhiBusy = false;
zhiAutoTick(); // 全自動開著就接著吱下一次
});
}
// ---------- 全自動吱吱 ----------
function setZhiAuto(on) {
state.zhiAuto = on;
clearTimeout(state.zhiAutoTimer);
state.zhiAutoTimer = null;
const btn = $("zhi-auto");
btn.textContent = t(on ? "zhi.auto_on" : "zhi.auto");
btn.classList.toggle("on", on);
btn.setAttribute("aria-pressed", String(on));
if (on) zhiAutoTick();
}
// 可以吱就吱一下(從畫面中央);正在播就等它播完再被叫一次;離上一下不到 1 秒就等滿再吱
function zhiAutoTick() {
if (!state.zhiAuto || state.zhiMode !== "more" || state.zhiBusy) return;
const wait = ZHI_GAP_MS - (Date.now() - state.zhiLastAt);
if (wait > 0) {
clearTimeout(state.zhiAutoTimer);
state.zhiAutoTimer = setTimeout(zhiAutoTick, wait);
return;
}
zhiMore(window.innerWidth / 2, window.innerHeight / 2);
}
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
// 把還沒送的次數一下一下送給伺服器(伺服器一個帳號一秒只收一下)
function flushZhi() {
clearTimeout(state.zhiTimer);
state.zhiTimer = null;
if (!state.zhiFlush) state.zhiFlush = sendZhi().finally(() => { state.zhiFlush = null; });
return state.zhiFlush;
}
async function sendZhi() {
while (state.zhiPending > 0) {
try {
const r = await api("POST", "/api/zhi", { n: 1 });
state.zhiPending--;
// 以伺服器的數字為準,再加上還沒送出的
if (state.today) state.today.clicks = r.clicks + state.zhiPending;
} catch (e) {
if (e.status === 401 || e.status === 400) { state.zhiPending = 0; return; } // 登出了:這幾下就不算
state.zhiTimer = setTimeout(flushZhi, ZHI_GAP_MS * 3); // 網路問題:留著等一下再送
return;
}
if (state.zhiPending > 0) await sleep(ZHI_GAP_MS);
}
if (state.zhiMode === "more") showZhiCount(false);
}
// 關掉分頁前把還沒送的那一下送出去(keepalive 讓請求在頁面關閉後繼續完成)
function flushZhiOnLeave() {
if (state.zhiPending <= 0 || state.zhiFlush) return; // 正在送的那個請求會自己完成
state.zhiPending--;
fetch("/api/zhi", {
method: "POST",
headers: { "X-ZHIWU": "1", "Content-Type": "application/json" },
credentials: "same-origin",
keepalive: true,
body: JSON.stringify({ n: 1 }),
}).catch(() => {});
}
async function exitStage() {
const mode = state.zhiMode;
closeStage();
if (mode === "more") {
$("done-stats").textContent = statsText(state.today); // 數字先更新,小卡等伺服器收到次數後再換
await flushZhi();
await refreshToday(); // 小卡換成新的吱吱次數
loadMe();
} else {
state.zhiSkipped = true; // 等等再吱:留在頁面上,可以用側欄
}
}
function bindCheckin() {
const stage = $("zhi-stage");
stage.addEventListener("click", (ev) => {
if (ev.target.closest("#zhi-exit, #zhi-auto")) return;
// 鍵盤觸發的 click 沒有座標,改從畫面中央噴
const x = ev.clientX || window.innerWidth / 2;
const y = ev.clientY || window.innerHeight / 2;
if (state.zhiMode === "checkin") zhiCheckin(x, y);
else if (state.zhiMode === "more") zhiMore(x, y);
});
$("zhi-exit").addEventListener("click", exitStage);
$("zhi-auto").addEventListener("click", () => setZhiAuto(!state.zhiAuto));
$("zhi-open").addEventListener("click", () => { state.zhiSkipped = false; openStage("checkin"); });
$("zhi-more").addEventListener("click", () => openStage("more"));
$("share-btn").addEventListener("click", shareCard);
window.addEventListener("pagehide", flushZhiOnLeave);
document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "hidden") flushZhiOnLeave();
});
}
// ---------- 畫面切換 ----------
function showView(id) {
for (const v of ["view-checkin", "view-user", "view-upload", "view-review"]) $(v).hidden = v !== id;
if (id !== "view-checkin") { clearInterval(state.resetTimer); closeStage(); }
}
// ---------- 投稿迷因圖 ----------
function renderUploads(r) {
$("upload-quota").textContent = t("upload.remaining", { n: r.remaining, max: r.limit });
$("upload-pick").classList.toggle("busy", r.remaining <= 0);
const list = $("upload-list");
list.replaceChildren();
$("upload-empty").hidden = r.items.length > 0;
for (const it of r.items) {
const box = document.createElement("div");
box.className = "sub-item";
if (it.image_url) {
const img = document.createElement("img");
img.src = it.image_url;
img.alt = "";
img.loading = "lazy";
box.append(img);
}
const badge = document.createElement("span");
badge.className = `sub-status ${it.status}`;
badge.textContent = t(`upload.status.${it.status}`);
box.append(badge);
list.append(box);
}
}
async function refreshUploads() {
try {
renderUploads(await api("GET", "/api/submissions"));
} catch (e) {
showError($("upload-error"), e);
$("upload-pick").classList.remove("busy");
}
}
async function showUpload() {
showView("view-upload");
document.title = `${t("nav.upload")} · ${SITE_TITLE}`;
showError($("upload-error"), null);
if (!state.me) { location.replace("/"); return; }
await refreshUploads();
}
function bindUpload() {
$("upload-file").addEventListener("change", async (ev) => {
const files = [...ev.target.files];
ev.target.value = "";
if (!files.length) return;
$("upload-pick").classList.add("busy");
showError($("upload-error"), null);
let ok = 0;
for (const file of files) { // 一張一張傳,額度用完就停
if (file.size > SUBMIT_MAX_BYTES) { showError($("upload-error"), { code: "file_too_large" }); continue; }
const fd = new FormData();
fd.append("file", file);
try {
await api("POST", "/api/submissions", fd);
ok++;
} catch (e) {
showError($("upload-error"), e);
if (e.code === "quota_exceeded") break;
}
}
if (ok) toast(t("upload.done", { n: ok }));
await refreshUploads();
});
}
// ---------- 管理員審核(一張一張) ----------
async function loadReview() {
try {
const r = await api("GET", "/api/admin/submissions");
$("review-left").textContent = t("review.left", { n: r.pending });
state.me.pending_reviews = r.pending;
renderSidebar();
const it = r.item;
$("review-item").hidden = !it;
$("review-empty").hidden = !!it;
if (!it) return;
$("review-item").dataset.id = it.id;
$("review-img").src = it.image_url;
$("review-name").textContent = it.uploader.display_name;
$("review-name").href = `/u/${it.uploader.uid_str}`;
showUid($("review-uid"), it.uploader);
$("review-time").textContent = new Date(it.created_at).toLocaleString(HTML_LANG[state.lang]);
} catch (e) {
if (e.status === 401 || e.status === 403) { location.replace("/"); return; }
toast(errText(e));
}
}
async function showReview() {
showView("view-review");
document.title = `${t("review.heading")} · ${SITE_TITLE}`;
if (!state.me?.is_admin) { location.replace("/"); return; }
await loadReview();
}
function bindReview() {
const buttons = [$("review-approve"), $("review-reject")];
const decide = async (action) => {
const sid = $("review-item").dataset.id;
buttons.forEach((b) => { b.disabled = true; });
try {
await api("POST", `/api/admin/submissions/${sid}/${action}`);
toast(t(`review.${action}d`));
} catch (e) {
// 已經審過(例如另一個分頁)就直接跳下一張
if (e.code !== "already_reviewed" && e.code !== "not_found") toast(errText(e));
} finally {
buttons.forEach((b) => { b.disabled = false; });
}
await loadReview();
};
$("review-approve").addEventListener("click", () => decide("approve"));
$("review-reject").addEventListener("click", () => decide("reject"));
}
// ---------- 個人頁 ----------
async function showUser(uid) {
showView("view-user");
try {
const u = await api("GET", `/api/users/${uid}?lang=${state.lang}`);
$("user-card").hidden = false;
$("user-missing").hidden = true;
$("user-avatar").src = u.avatar_url || DEFAULT_AVATAR;
$("user-name").textContent = u.display_name;
showUid($("user-uid"), u);
// 管理員:下面多一個設定這個 UID 顏色與稱號的表單
const form = $("title-form");
form.hidden = !state.me?.is_admin;
form.dataset.uid = u.uid;
$("title-text").value = u.title || "";
$("title-color").value = u.title_color || "#ff8a1f";
showError($("title-error"), null);
$("user-stats").textContent = statsText(u);
const bio = $("user-bio");
if (u.bio_md.trim()) {
bio.innerHTML = u.bio_html; // 伺服器端已關閉原始 HTML
bio.classList.remove("empty");
} else {
bio.textContent = t("user.no_bio");
bio.classList.add("empty");
}
const joined = new Date(u.created_at).toLocaleDateString(HTML_LANG[state.lang]);
$("user-joined").textContent = t("user.joined", { d: joined });
document.title = `${u.display_name} · ${SITE_TITLE}`;
} catch {
$("user-card").hidden = true;
$("user-missing").hidden = false;
}
}
// ---------- 管理員:指定 UID 的顏色與稱號 ----------
function bindTitle() {
const form = $("title-form");
const save = async (body) => {
try {
const u = await api("PUT", `/api/admin/users/${form.dataset.uid}/title`, body);
state.cardBust = Date.now();
toast(t("title.saved"));
if (state.me && u.uid === state.me.uid) await loadMe();
await showUser(u.uid_str);
} catch (e) {
showError($("title-error"), e);
}
};
form.addEventListener("submit", (ev) => {
ev.preventDefault();
withBusy($("title-save"), () => save({ title: $("title-text").value, color: $("title-color").value }));
});
$("title-clear").addEventListener("click", () => withBusy($("title-clear"), () => save({ title: "", color: "" })));
}
// ---------- 編輯個人資料 ----------
function bindProfile() {
const dialog = $("profile-dialog");
$("edit-profile").addEventListener("click", () => {
const me = state.me;
$("edit-avatar").src = me.avatar_url || DEFAULT_AVATAR;
$("edit-name").value = me.display_name;
$("edit-bio").value = me.bio_md;
setPreview(false);
showError($("profile-error"), null);
closeMenu();
dialog.showModal();
});
$("profile-cancel").addEventListener("click", () => dialog.close());
$("avatar-file").addEventListener("change", async (ev) => {
const file = ev.target.files[0];
ev.target.value = "";
if (!file) return;
if (file.size > 5 * 1024 * 1024) return showError($("profile-error"), { code: "file_too_large" });
const fd = new FormData();
fd.append("file", file);
try {
state.me = await api("PUT", "/api/me/avatar", fd);
state.cardBust = Date.now();
$("edit-avatar").src = state.me.avatar_url;
showError($("profile-error"), null);
renderSidebar();
} catch (e) {
showError($("profile-error"), e);
}
});
$("preview-toggle").addEventListener("click", async () => {
if (!$("edit-preview").hidden) return setPreview(false);
try {
const r = await api("POST", "/api/markdown", { md: $("edit-bio").value });
$("edit-preview").innerHTML = r.html;
setPreview(true);
} catch (e) {
showError($("profile-error"), e);
}
});
$("profile-form").addEventListener("submit", (ev) => {
ev.preventDefault();
withBusy($("profile-save"), async () => {
try {
state.me = await api("PATCH", "/api/me", {
display_name: $("edit-name").value,
bio_md: $("edit-bio").value,
});
state.cardBust = Date.now();
dialog.close();
toast(t("profile.saved"));
renderSidebar();
await route();
} catch (e) {
showError($("profile-error"), e);
}
});
});
}
function setPreview(on) {
$("edit-preview").hidden = !on;
$("edit-bio").hidden = on;
$("preview-toggle").textContent = on ? t("profile.edit_back") : t("profile.preview");
}
// ---------- 手機選單 ----------
function openMenu() { $("sidebar").classList.add("open"); }
function closeMenu() { $("sidebar").classList.remove("open"); }
// ---------- 啟動 ----------
async function loadMe() {
try {
state.me = await api("GET", "/api/me");
} catch {
state.me = null;
}
renderSidebar();
}
async function route() {
document.title = HOME_TITLE;
const m = location.pathname.match(/^\/u\/(\d+)$/);
if (m) return showUser(m[1]);
if (location.pathname === "/upload") return showUpload();
if (location.pathname === "/review") return showReview();
return showCheckin();
}
async function init() {
await loadLang(detectLang());
bindAuth();
bindCheckin();
bindProfile();
bindTitle();
bindUpload();
bindReview();
$("menu-toggle").addEventListener("click", () => $("sidebar").classList.toggle("open"));
$("lang").addEventListener("change", async (ev) => {
await loadLang(ev.target.value);
if (state.me) {
try {
// 語言也會用在信件、小卡與分享文字,所以同步到伺服器
state.me = await api("PATCH", "/api/me", { lang: state.lang });
state.cardBust = Date.now();
} catch { /* 介面已經切換,伺服器同步失敗就算了 */ }
}
renderSidebar();
if (!$("code-form").hidden) $("code-sent-msg").textContent = t("auth.sent", { email: state.email });
if (state.zhiMode) { // 全螢幕畫面上的按鈕文字不是 data-i18n,換語言時重填
$("zhi-exit").textContent = t(state.zhiMode === "more" ? "zhi.back" : "zhi.later");
$("zhi-auto").textContent = t(state.zhiAuto ? "zhi.auto_on" : "zhi.auto");
showZhiCount(false);
}
await route();
});
await loadMe();
await route();
}
init();
Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" fill="#5a3a1c"/><circle cx="32" cy="25" r="12" fill="#d9a066"/><path d="M10 60c2-13 11-20 22-20s20 7 22 20z" fill="#d9a066"/></svg>

After

Width:  |  Height:  |  Size: 221 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

+99
View File
@@ -0,0 +1,99 @@
{
"lang.label": "Language",
"menu": "Menu",
"auth.heading": "Log in / Sign up",
"auth.hint": "We'll email you a code. Your account is created the first time you log in.",
"auth.email": "Email",
"auth.send": "Send code",
"auth.sent": "We sent a code to {email}. It expires in 5 minutes.",
"auth.code": "6-digit code",
"auth.verify": "Log in",
"auth.resend": "Resend",
"auth.resend_wait": "Resend in {s}s",
"auth.change_email": "Use a different email",
"auth.logout": "Log out",
"profile.view": "My profile",
"profile.edit": "Edit profile",
"profile.avatar": "Avatar",
"profile.avatar_hint": "Cropped to a 1024×1024 square, up to 5 MB",
"profile.avatar_change": "Change avatar",
"profile.name": "Name",
"profile.bio": "About me (Markdown supported)",
"profile.preview": "Preview",
"profile.edit_back": "Keep editing",
"profile.save": "Save",
"profile.cancel": "Cancel",
"profile.saved": "Saved",
"checkin.login_first": "Log in to squeak in once a day and get a squeak card.",
"checkin.ready": "You haven't squeaked today",
"checkin.success": "Squeaked!",
"checkin.done_today": "You've already squeaked today",
"checkin.total": "{n} days total",
"checkin.streak": "{n}-day streak",
"checkin.next": "Next check-in: {time} (in {t})",
"share.button": "Share",
"share.download": "Download image",
"share.copied": "Copied the share text and link",
"user.joined": "Joined {d}",
"user.not_found": "User not found",
"user.back": "Back to home",
"user.no_bio": "No bio yet.",
"err.invalid_email": "That email address doesn't look right",
"err.too_many_requests": "Too many requests. Please try again later",
"err.send_failed": "Couldn't send the email. Please try again later",
"err.not_requested": "Send a code first",
"err.expired": "This code has expired. Send a new one",
"err.wrong_code": "Wrong code",
"err.unauthorized": "Please log in",
"err.name_invalid": "Names must be 1–32 characters",
"err.bio_too_long": "Your bio can be up to 2000 characters",
"err.file_too_large": "File too large (5 MB max)",
"err.invalid_image": "Couldn't read that image",
"err.network": "Connection failed",
"err.unknown": "Something went wrong",
"err.code_used": "This code has already been used. Please get a new code in a moment",
"nav.upload": "Submit images",
"nav.review": "Review submissions ({n})",
"upload.heading": "Submit images",
"upload.hint": "Upload images you think belong on a squeak card. Approved images join the draw. Up to 5 per day (resets at 04:00 Taiwan time), 5MB each.",
"upload.choose": "Choose images",
"upload.remaining": "{n} / {max} uploads left today",
"upload.done": "Uploaded {n}, waiting for review",
"upload.mine": "My submissions",
"upload.empty": "No submissions yet.",
"upload.status.pending": "Pending",
"upload.status.approved": "Added",
"upload.status.rejected": "Not accepted",
"review.heading": "Review submissions",
"review.left": "{n} waiting",
"review.approve": "Approve",
"review.reject": "Reject",
"review.approved": "Approved and added to the draw",
"review.rejected": "Rejected",
"review.empty": "Nothing to review right now",
"err.quota_exceeded": "You've used today's uploads. Come back tomorrow",
"err.forbidden": "Not allowed",
"err.already_reviewed": "This one has already been reviewed",
"err.not_found": "Not found",
"site.tagline": "Have you squeaked today?",
"zhi.hint": "Tap to squeak",
"zhi.more": "Keep squeaking",
"zhi.back": "Back to card",
"zhi.later": "Squeak later",
"zhi.count": "{n} squeaks",
"zhi.open": "Go squeak",
"checkin.clicks": "{n} squeaks",
"err.bad_request": "Bad request",
"zhi.auto": "Auto squeak",
"zhi.auto_on": "Auto squeaking (tap to stop)",
"title.heading": "Title & colour (admin)",
"title.name": "Title",
"title.color": "Colour",
"title.hint": "The colour is applied to the UID and the title, shown in the sidebar, profile and card. The title may be left empty.",
"title.save": "Apply",
"title.clear": "Clear",
"title.saved": "Title updated",
"err.title_too_long": "Titles can be up to 16 characters",
"err.invalid_color": "Invalid colour",
"err.user_not_found": "User not found"
}
+99
View File
@@ -0,0 +1,99 @@
{
"lang.label": "言語",
"menu": "メニュー",
"auth.heading": "ログイン / 登録",
"auth.hint": "メールアドレスに認証コードを送ります。初回ログイン時にアカウントが作成されます。",
"auth.email": "メールアドレス",
"auth.send": "認証コードを送信",
"auth.sent": "{email} に認証コードを送りました(有効期限 5 分)。",
"auth.code": "6 桁の認証コード",
"auth.verify": "ログイン",
"auth.resend": "再送信",
"auth.resend_wait": "{s} 秒後に再送信できます",
"auth.change_email": "別のメールアドレスを使う",
"auth.logout": "ログアウト",
"profile.view": "マイページ",
"profile.edit": "プロフィール編集",
"profile.avatar": "アイコン",
"profile.avatar_hint": "1024×1024 の正方形に切り抜きます(最大 5MB)",
"profile.avatar_change": "アイコンを変更",
"profile.name": "名前",
"profile.bio": "自己紹介(Markdown 対応)",
"profile.preview": "プレビュー",
"profile.edit_back": "編集に戻る",
"profile.save": "保存",
"profile.cancel": "キャンセル",
"profile.saved": "保存しました",
"checkin.login_first": "ログインすると毎日 1 回チューチューして、カードがもらえます。",
"checkin.ready": "今日はまだチューチューしていません",
"checkin.success": "チューチュー成功!",
"checkin.done_today": "今日はもうチューチュー済みです",
"checkin.total": "累計 {n} 日",
"checkin.streak": "連続 {n} 日",
"checkin.next": "次回:{time}(あと {t})",
"share.button": "シェア",
"share.download": "画像を保存",
"share.copied": "シェア用のテキストとリンクをコピーしました",
"user.joined": "{d} に参加",
"user.not_found": "ユーザーが見つかりません",
"user.back": "トップへ",
"user.no_bio": "自己紹介はまだありません。",
"err.invalid_email": "メールアドレスの形式が正しくありません",
"err.too_many_requests": "リクエストが多すぎます。しばらくしてからお試しください",
"err.send_failed": "メールを送信できませんでした。しばらくしてからお試しください",
"err.not_requested": "先に認証コードを送信してください",
"err.expired": "認証コードが無効になりました。再送信してください",
"err.wrong_code": "認証コードが違います",
"err.unauthorized": "ログインしてください",
"err.name_invalid": "名前は 1〜32 文字にしてください",
"err.bio_too_long": "自己紹介は 2000 文字までです",
"err.file_too_large": "ファイルが大きすぎます(最大 5MB)",
"err.invalid_image": "この画像は読み込めません",
"err.network": "接続できませんでした",
"err.unknown": "エラーが発生しました",
"err.code_used": "この認証コードは使用済みです。しばらくしてから新しいコードをお使いください",
"nav.upload": "画像を投稿",
"nav.review": "投稿の審査({n})",
"upload.heading": "画像を投稿",
"upload.hint": "カードに載せたい画像をアップロードしてください。審査に通るとガチャに追加されます。1日5枚まで(台湾時間 04:00 にリセット)、5MBまで。",
"upload.choose": "画像を選ぶ",
"upload.remaining": "今日はあと {n} / {max} 枚",
"upload.done": "{n} 枚アップロードしました(審査待ち)",
"upload.mine": "自分の投稿",
"upload.empty": "まだ投稿がありません。",
"upload.status.pending": "審査中",
"upload.status.approved": "採用",
"upload.status.rejected": "不採用",
"review.heading": "投稿の審査",
"review.left": "審査待ち {n} 枚",
"review.approve": "採用",
"review.reject": "却下",
"review.approved": "採用しました",
"review.rejected": "却下しました",
"review.empty": "審査待ちの投稿はありません",
"err.quota_exceeded": "今日の投稿枠を使い切りました。また明日どうぞ",
"err.forbidden": "権限がありません",
"err.already_reviewed": "この投稿はすでに審査済みです",
"err.not_found": "見つかりません",
"site.tagline": "今日はもうチューチューした?",
"zhi.hint": "タップしてチューチュー",
"zhi.more": "もっとチューチュー",
"zhi.back": "カードに戻る",
"zhi.later": "あとでチューチュー",
"zhi.count": "チューチュー {n} 回",
"zhi.open": "チューチューしに行く",
"checkin.clicks": "チューチュー {n} 回",
"err.bad_request": "リクエストが正しくありません",
"zhi.auto": "全自動チューチュー",
"zhi.auto_on": "全自動チューチュー中(タップで停止)",
"title.heading": "称号と色(管理者)",
"title.name": "称号",
"title.color": "色",
"title.hint": "色は UID と称号に適用され、サイドバー・プロフィール・カードに表示されます。称号は空欄でも構いません。",
"title.save": "適用",
"title.clear": "クリア",
"title.saved": "称号を更新しました",
"err.title_too_long": "称号は 16 文字までです",
"err.invalid_color": "色の形式が正しくありません",
"err.user_not_found": "ユーザーが見つかりません"
}
+99
View File
@@ -0,0 +1,99 @@
{
"lang.label": "언어",
"menu": "메뉴",
"auth.heading": "로그인 / 가입",
"auth.hint": "이메일로 인증 코드를 보내드립니다. 처음 로그인하면 계정이 자동으로 만들어집니다.",
"auth.email": "이메일",
"auth.send": "인증 코드 보내기",
"auth.sent": "{email}(으)로 인증 코드를 보냈습니다. 5분 동안 유효합니다.",
"auth.code": "6자리 인증 코드",
"auth.verify": "로그인",
"auth.resend": "다시 보내기",
"auth.resend_wait": "{s}초 후 다시 보낼 수 있습니다",
"auth.change_email": "다른 이메일 사용",
"auth.logout": "로그아웃",
"profile.view": "내 프로필",
"profile.edit": "프로필 편집",
"profile.avatar": "프로필 사진",
"profile.avatar_hint": "1024×1024 정사각형으로 잘립니다 (최대 5MB)",
"profile.avatar_change": "사진 변경",
"profile.name": "이름",
"profile.bio": "자기소개 (Markdown 지원)",
"profile.preview": "미리보기",
"profile.edit_back": "계속 편집",
"profile.save": "저장",
"profile.cancel": "취소",
"profile.saved": "저장했습니다",
"checkin.login_first": "로그인하면 하루에 한 번 찍찍 출석하고 카드를 받을 수 있습니다.",
"checkin.ready": "오늘은 아직 찍찍하지 않았어요",
"checkin.success": "찍찍 성공!",
"checkin.done_today": "오늘은 이미 찍찍했어요",
"checkin.total": "누적 {n}일",
"checkin.streak": "연속 {n}일",
"checkin.next": "다음 출석: {time} ({t} 남음)",
"share.button": "공유",
"share.download": "이미지 저장",
"share.copied": "공유 문구와 링크를 복사했습니다",
"user.joined": "{d} 가입",
"user.not_found": "사용자를 찾을 수 없습니다",
"user.back": "홈으로",
"user.no_bio": "아직 자기소개가 없습니다.",
"err.invalid_email": "이메일 형식이 올바르지 않습니다",
"err.too_many_requests": "요청이 너무 많습니다. 잠시 후 다시 시도해 주세요",
"err.send_failed": "메일을 보내지 못했습니다. 잠시 후 다시 시도해 주세요",
"err.not_requested": "먼저 인증 코드를 보내 주세요",
"err.expired": "인증 코드가 만료되었습니다. 다시 보내 주세요",
"err.wrong_code": "인증 코드가 틀렸습니다",
"err.unauthorized": "로그인해 주세요",
"err.name_invalid": "이름은 1~32자여야 합니다",
"err.bio_too_long": "자기소개는 최대 2000자입니다",
"err.file_too_large": "파일이 너무 큽니다 (최대 5MB)",
"err.invalid_image": "이미지를 읽을 수 없습니다",
"err.network": "연결에 실패했습니다",
"err.unknown": "오류가 발생했습니다",
"err.code_used": "이미 사용한 인증 코드입니다. 잠시 후 새 코드를 사용해 주세요",
"nav.upload": "이미지 투고",
"nav.review": "투고 심사 ({n})",
"upload.heading": "이미지 투고",
"upload.hint": "카드에 넣고 싶은 이미지를 올려 주세요. 심사를 통과하면 뽑기에 추가됩니다. 하루 최대 5장(대만 시간 04:00 초기화), 5MB까지.",
"upload.choose": "이미지 선택",
"upload.remaining": "오늘 {n} / {max}장 더 올릴 수 있어요",
"upload.done": "{n}장 업로드했어요 (심사 대기)",
"upload.mine": "내 투고",
"upload.empty": "아직 투고한 이미지가 없어요.",
"upload.status.pending": "심사 중",
"upload.status.approved": "채택",
"upload.status.rejected": "미채택",
"review.heading": "투고 심사",
"review.left": "심사 대기 {n}장",
"review.approve": "승인",
"review.reject": "거절",
"review.approved": "승인했어요",
"review.rejected": "거절했어요",
"review.empty": "심사할 투고가 없어요",
"err.quota_exceeded": "오늘 투고 한도를 다 썼어요. 내일 다시 와 주세요",
"err.forbidden": "권한이 없어요",
"err.already_reviewed": "이미 심사한 투고예요",
"err.not_found": "찾을 수 없어요",
"site.tagline": "오늘 찍찍 했어?",
"zhi.hint": "눌러서 찍찍",
"zhi.more": "계속 찍찍",
"zhi.back": "카드로 돌아가기",
"zhi.later": "나중에 찍찍",
"zhi.count": "찍찍 {n}번",
"zhi.open": "찍찍하러 가기",
"checkin.clicks": "찍찍 {n}번",
"err.bad_request": "잘못된 요청입니다",
"zhi.auto": "자동 찍찍",
"zhi.auto_on": "자동 찍찍 중 (눌러서 멈추기)",
"title.heading": "칭호와 색상 (관리자)",
"title.name": "칭호",
"title.color": "색상",
"title.hint": "색상은 UID와 칭호에 적용되어 사이드바, 프로필, 카드에 표시됩니다. 칭호는 비워 둘 수 있습니다.",
"title.save": "적용",
"title.clear": "지우기",
"title.saved": "칭호를 업데이트했습니다",
"err.title_too_long": "칭호는 최대 16자입니다",
"err.invalid_color": "색상 형식이 올바르지 않습니다",
"err.user_not_found": "사용자를 찾을 수 없습니다"
}
+99
View File
@@ -0,0 +1,99 @@
{
"lang.label": "语言",
"menu": "菜单",
"auth.heading": "登录 / 注册",
"auth.hint": "输入邮箱接收验证码,第一次登录会自动创建账号。",
"auth.email": "邮箱",
"auth.send": "发送验证码",
"auth.sent": "验证码已发送到 {email},5 分钟内有效。",
"auth.code": "6 位数验证码",
"auth.verify": "登录",
"auth.resend": "重新发送",
"auth.resend_wait": "{s} 秒后可重发",
"auth.change_email": "换一个邮箱",
"auth.logout": "退出登录",
"profile.view": "我的主页",
"profile.edit": "编辑个人资料",
"profile.avatar": "头像",
"profile.avatar_hint": "会裁成 1024×1024 正方形,上限 5MB",
"profile.avatar_change": "更换头像",
"profile.name": "名称",
"profile.bio": "自我介绍(支持 Markdown)",
"profile.preview": "预览",
"profile.edit_back": "继续编辑",
"profile.save": "保存",
"profile.cancel": "取消",
"profile.saved": "已保存",
"checkin.login_first": "不是松鼠,是鼯鼠。登录后每天吱吱签到一次,领一张吱吱小卡。",
"checkin.ready": "今天还没吱吱",
"checkin.success": "吱吱成功!",
"checkin.done_today": "今天已经吱吱过了",
"checkin.total": "累计 {n} 天",
"checkin.streak": "连续 {n} 天",
"checkin.next": "下次签到:{time}(还有 {t})",
"share.button": "分享",
"share.download": "下载图片",
"share.copied": "已复制分享文字和链接",
"user.joined": "{d} 加入",
"user.not_found": "找不到这个用户",
"user.back": "回首页",
"user.no_bio": "这个人还没写自我介绍。",
"err.invalid_email": "邮箱格式不正确",
"err.too_many_requests": "请求太频繁,请稍后再试",
"err.send_failed": "验证邮件发送失败,请稍后再试",
"err.not_requested": "请先发送验证码",
"err.expired": "验证码已失效,请重新发送",
"err.wrong_code": "验证码错误",
"err.unauthorized": "请先登录",
"err.name_invalid": "名称需要 1–32 个字",
"err.bio_too_long": "自我介绍最多 2000 字",
"err.file_too_large": "文件太大(上限 5MB)",
"err.invalid_image": "无法读取这张图片",
"err.network": "连接失败,请检查网络",
"err.unknown": "发生错误,请稍后再试",
"err.code_used": "这组验证码已经用过,请稍后获取新的验证码",
"nav.upload": "投稿图片",
"nav.review": "审核投稿({n})",
"upload.heading": "投稿图片",
"upload.hint": "上传你觉得适合放上小卡的图,审核通过后就会加入抽卡。每天最多 5 张(台湾时间 04:00 重置),上限 5MB。",
"upload.choose": "选择图片",
"upload.remaining": "今天还能上传 {n} / {max} 张",
"upload.done": "已上传 {n} 张,等待审核",
"upload.mine": "我的投稿",
"upload.empty": "还没有投稿过。",
"upload.status.pending": "审核中",
"upload.status.approved": "已加入",
"upload.status.rejected": "未通过",
"review.heading": "审核投稿",
"review.left": "待审 {n} 张",
"review.approve": "同意",
"review.reject": "拒绝",
"review.approved": "已同意,加入抽卡",
"review.rejected": "已拒绝",
"review.empty": "目前没有待审的投稿",
"err.quota_exceeded": "今天的投稿额度已经用完,明天再来",
"err.forbidden": "没有权限",
"err.already_reviewed": "这张已经审核过了",
"err.not_found": "找不到",
"site.tagline": "你今天吱吱了吗",
"zhi.hint": "点击吱吱",
"zhi.more": "继续吱吱",
"zhi.back": "回到小卡",
"zhi.later": "等等再吱",
"zhi.count": "吱吱 {n} 次",
"zhi.open": "去吱吱",
"checkin.clicks": "吱吱 {n} 次",
"err.bad_request": "请求格式不正确",
"zhi.auto": "全自动吱吱",
"zhi.auto_on": "全自动吱吱中(点我停止)",
"title.heading": "称号与颜色(管理员)",
"title.name": "称号",
"title.color": "颜色",
"title.hint": "颜色会套在 UID 和称号上,显示在侧栏、个人页和小卡。称号可以留空,只上颜色。",
"title.save": "应用",
"title.clear": "清除",
"title.saved": "已更新称号",
"err.title_too_long": "称号最多 16 个字",
"err.invalid_color": "颜色格式不正确",
"err.user_not_found": "找不到这个用户"
}
+99
View File
@@ -0,0 +1,99 @@
{
"lang.label": "語言",
"menu": "選單",
"auth.heading": "登入 / 註冊",
"auth.hint": "輸入信箱收驗證碼,第一次登入會自動建立帳號。",
"auth.email": "信箱",
"auth.send": "寄送驗證碼",
"auth.sent": "驗證碼已寄到 {email},5 分鐘內有效。",
"auth.code": "6 位數驗證碼",
"auth.verify": "登入",
"auth.resend": "重新寄送",
"auth.resend_wait": "{s} 秒後可重寄",
"auth.change_email": "換一個信箱",
"auth.logout": "登出",
"profile.view": "我的個人頁",
"profile.edit": "編輯個人資料",
"profile.avatar": "大頭貼",
"profile.avatar_hint": "會裁成 1024×1024 正方形,上限 5MB",
"profile.avatar_change": "更換大頭貼",
"profile.name": "名稱",
"profile.bio": "自我介紹(支援 Markdown)",
"profile.preview": "預覽",
"profile.edit_back": "繼續編輯",
"profile.save": "儲存",
"profile.cancel": "取消",
"profile.saved": "已儲存",
"checkin.login_first": "不是松鼠,是鼯鼠。登入後每天吱吱簽到一次,領一張吱吱小卡。",
"checkin.ready": "今天還沒吱吱",
"checkin.success": "吱吱成功!",
"checkin.done_today": "今天已經吱吱過了",
"checkin.total": "累計 {n} 天",
"checkin.streak": "連續 {n} 天",
"checkin.next": "下次簽到:{time}(還有 {t})",
"share.button": "分享",
"share.download": "下載圖片",
"share.copied": "已複製分享文字和連結",
"user.joined": "{d} 加入",
"user.not_found": "找不到這個使用者",
"user.back": "回首頁",
"user.no_bio": "這隻鼯鼠還沒寫自我介紹。",
"err.invalid_email": "信箱格式不正確",
"err.too_many_requests": "請求太頻繁,請稍後再試",
"err.send_failed": "驗證信寄送失敗,請稍後再試",
"err.not_requested": "請先寄送驗證碼",
"err.expired": "驗證碼已失效,請重新寄送",
"err.wrong_code": "驗證碼錯誤",
"err.unauthorized": "請先登入",
"err.name_invalid": "名稱需要 1–32 個字",
"err.bio_too_long": "自我介紹最多 2000 字",
"err.file_too_large": "檔案太大(上限 5MB)",
"err.invalid_image": "無法讀取這張圖片",
"err.network": "連線失敗,請檢查網路",
"err.unknown": "發生錯誤,請稍後再試",
"err.code_used": "這組驗證碼已經用過,請稍後取得新的驗證碼",
"nav.upload": "投稿圖片",
"nav.review": "審核投稿({n})",
"upload.heading": "投稿圖片",
"upload.hint": "上傳你覺得適合放上吱吱小卡的圖,審核通過後就會加入抽卡。每天最多 5 張(台灣時間 04:00 重置),上限 5MB。",
"upload.choose": "選擇圖片",
"upload.remaining": "今天還能上傳 {n} / {max} 張",
"upload.done": "已上傳 {n} 張,等待審核",
"upload.mine": "我的投稿",
"upload.empty": "還沒有投稿過。",
"upload.status.pending": "審核中",
"upload.status.approved": "已加入",
"upload.status.rejected": "未通過",
"review.heading": "審核投稿",
"review.left": "待審 {n} 張",
"review.approve": "同意",
"review.reject": "拒絕",
"review.approved": "已同意,加入抽卡",
"review.rejected": "已拒絕",
"review.empty": "目前沒有待審的投稿",
"err.quota_exceeded": "今天的投稿額度已經用完,明天再來",
"err.forbidden": "沒有權限",
"err.already_reviewed": "這張已經審核過了",
"err.not_found": "找不到",
"site.tagline": "你今天吱吱了嗎",
"zhi.hint": "點擊吱吱",
"zhi.more": "繼續吱吱",
"zhi.back": "回到小卡",
"zhi.later": "等等再吱",
"zhi.count": "吱吱 {n} 次",
"zhi.open": "去吱吱",
"checkin.clicks": "吱吱 {n} 次",
"err.bad_request": "請求格式不正確",
"zhi.auto": "全自動吱吱",
"zhi.auto_on": "全自動吱吱中(點我停止)",
"title.heading": "稱號與顏色(管理員)",
"title.name": "稱號",
"title.color": "顏色",
"title.hint": "顏色會套在 UID 和稱號上,顯示在側欄、個人頁和小卡。稱號可以留空,只上顏色。",
"title.save": "套用",
"title.clear": "清除",
"title.saved": "已更新稱號",
"err.title_too_long": "稱號最多 16 個字",
"err.invalid_color": "顏色格式不正確",
"err.user_not_found": "找不到這個使用者"
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

+212
View File
@@ -0,0 +1,212 @@
<!DOCTYPE html>
<html lang="zh-Hant-TW">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>吱鼯計畫<!--BETA_TITLE--> — 你今天吱吱了嗎</title>
<meta name="description" content="吱鼯計畫:你今天吱吱了嗎">
<meta name="theme-color" content="#1a0f06">
<link rel="icon" href="/favicon.ico" sizes="48x48">
<link rel="icon" href="/assets/icon-192.png" type="image/png" sizes="192x192">
<link rel="apple-touch-icon" href="/assets/apple-touch-icon.png">
<link rel="manifest" href="/assets/manifest.webmanifest">
<meta name="asset-version" content="__ASSET_VERSION__">
<link rel="stylesheet" href="/assets/style.css?v=__ASSET_VERSION__">
<script type="module" src="/assets/app.js?v=__ASSET_VERSION__"></script>
<link rel="preload" as="image" href="/assets/media/zhizhi-poster.webp?v=__ASSET_VERSION__">
</head>
<body>
<div class="layout">
<aside id="sidebar">
<div class="brand">
<a href="/"><img class="logo" src="/assets/logo.png" alt="" width="32" height="32"><span class="brand-text"><b>吱鼯計畫<!--BETA_BADGE--></b><small data-i18n="site.tagline"></small></span></a>
<button id="menu-toggle" class="icon-btn only-mobile" type="button" data-i18n-aria="menu">☰</button>
</div>
<div id="sidebar-body">
<section id="auth-box" hidden>
<h2 data-i18n="auth.heading"></h2>
<p class="hint" data-i18n="auth.hint"></p>
<form id="email-form" novalidate>
<label><span data-i18n="auth.email"></span>
<input type="text" inputmode="email" id="email" required autocomplete="username" autocapitalize="off" spellcheck="false" maxlength="254">
</label>
<button type="submit" class="primary" data-i18n="auth.send"></button>
</form>
<form id="code-form" hidden novalidate>
<p class="hint" id="code-sent-msg"></p>
<label><span data-i18n="auth.code"></span>
<input id="code" inputmode="numeric" maxlength="6" autocomplete="one-time-code" required>
</label>
<button type="submit" class="primary" data-i18n="auth.verify"></button>
<div class="row">
<button type="button" class="link" id="resend"></button>
<button type="button" class="link" id="change-email" data-i18n="auth.change_email"></button>
</div>
</form>
<p class="error" id="auth-error" hidden></p>
</section>
<section id="me-box" hidden>
<img id="me-avatar" class="avatar" alt="" width="96" height="96">
<div class="me-name" id="me-name"></div>
<div class="uid" id="me-uid"></div>
<nav class="me-nav">
<a id="me-link" href="/" data-i18n="profile.view"></a>
<a id="upload-link" href="/upload" data-i18n="nav.upload"></a>
<a id="review-link" href="/review" hidden></a>
<button type="button" class="link" id="edit-profile" data-i18n="profile.edit"></button>
<button type="button" class="link" id="logout" data-i18n="auth.logout"></button>
</nav>
</section>
<label class="lang"><span data-i18n="lang.label"></span>
<select id="lang">
<option value="zh-TW">繁體中文</option>
<option value="zh-CN">简体中文</option>
<option value="ja">日本語</option>
<option value="ko">한국어</option>
<option value="en">English</option>
</select>
</label>
</div>
</aside>
<main id="main">
<section id="view-checkin" hidden>
<div id="checkin-guest" class="center" hidden>
<img class="big-logo" src="/assets/icon-192.png" alt="" width="120" height="120">
<div class="big-mark">吱鼯計畫</div>
<p class="tagline" data-i18n="site.tagline"></p>
<p class="muted" data-i18n="checkin.login_first"></p>
<button id="guest-login" class="primary" type="button" data-i18n="auth.heading"></button>
</div>
<!-- 今天還沒簽到、但先把全螢幕的吱吱畫面關掉(等等再吱)時顯示 -->
<div id="checkin-ready" class="center" hidden>
<p class="muted" data-i18n="checkin.ready"></p>
<button id="zhi-open" class="zhi-open" type="button">
<img src="/assets/media/zhizhi-poster.webp?v=__ASSET_VERSION__" alt="" width="1080" height="1920" draggable="false">
<span class="zhi-open-label" data-i18n="zhi.open"></span>
</button>
<p class="stats" id="ready-stats"></p>
</div>
<div id="checkin-done" class="center" hidden>
<p class="checkin-msg" id="checkin-msg"></p>
<img id="card-img" class="card-img" alt="" width="1080" height="1350">
<div class="row actions">
<button id="share-btn" class="primary" type="button" data-i18n="share.button"></button>
<a id="download-btn" class="button" download data-i18n="share.download"></a>
<button id="zhi-more" type="button" data-i18n="zhi.more"></button>
</div>
<p class="stats" id="done-stats"></p>
</div>
<p class="hint center-text" id="next-reset" hidden></p>
</section>
<section id="view-upload" hidden>
<h1 data-i18n="upload.heading"></h1>
<p class="hint" data-i18n="upload.hint"></p>
<div class="row upload-bar">
<label class="button primary" for="upload-file" id="upload-pick" data-i18n="upload.choose"></label>
<input type="file" id="upload-file" accept="image/*" multiple hidden>
<span class="muted" id="upload-quota"></span>
</div>
<p class="error" id="upload-error" hidden></p>
<h2 data-i18n="upload.mine"></h2>
<p class="hint" id="upload-empty" data-i18n="upload.empty" hidden></p>
<div class="sub-grid" id="upload-list"></div>
</section>
<section id="view-review" hidden>
<h1 data-i18n="review.heading"></h1>
<p class="muted" id="review-left"></p>
<div id="review-item" class="center" hidden>
<img id="review-img" class="review-img" alt="">
<p class="review-meta">
<a id="review-name" href="/"></a> <span class="uid" id="review-uid"></span><br>
<span class="hint" id="review-time"></span>
</p>
<div class="row actions">
<button type="button" id="review-reject" data-i18n="review.reject"></button>
<button type="button" class="primary" id="review-approve" data-i18n="review.approve"></button>
</div>
</div>
<p class="center-text muted" id="review-empty" data-i18n="review.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">
<h1 id="user-name"></h1>
<div class="uid" id="user-uid"></div>
<p class="stats" id="user-stats"></p>
<div class="bio" id="user-bio"></div>
<p class="hint" id="user-joined"></p>
<!-- 管理員才看得到:指定這個 UID 的顏色與稱號 -->
<form id="title-form" class="title-form" hidden novalidate>
<h2 data-i18n="title.heading"></h2>
<div class="row">
<label class="grow"><span data-i18n="title.name"></span>
<input id="title-text" maxlength="16" autocomplete="off">
</label>
<label><span data-i18n="title.color"></span>
<input id="title-color" type="color" value="#ff8a1f">
</label>
</div>
<p class="hint" data-i18n="title.hint"></p>
<p class="error" id="title-error" hidden></p>
<div class="row">
<span class="spacer"></span>
<button type="button" id="title-clear" data-i18n="title.clear"></button>
<button type="submit" class="primary" id="title-save" data-i18n="title.save"></button>
</div>
</form>
</div>
<p id="user-missing" class="center-text" hidden data-i18n="user.not_found"></p>
<p class="center-text"><a href="/" data-i18n="user.back"></a></p>
</section>
</main>
</div>
<dialog id="profile-dialog">
<form id="profile-form" method="dialog" novalidate>
<h2 data-i18n="profile.edit"></h2>
<div class="avatar-edit">
<img id="edit-avatar" class="avatar" alt="" width="96" height="96">
<div>
<label class="button" for="avatar-file" data-i18n="profile.avatar_change"></label>
<input type="file" id="avatar-file" accept="image/*" hidden>
<p class="hint" data-i18n="profile.avatar_hint"></p>
</div>
</div>
<label><span data-i18n="profile.name"></span>
<input id="edit-name" maxlength="32" required>
</label>
<label><span data-i18n="profile.bio"></span>
<textarea id="edit-bio" rows="8" maxlength="2000"></textarea>
</label>
<div class="bio preview" id="edit-preview" hidden></div>
<p class="error" id="profile-error" hidden></p>
<div class="row dialog-actions">
<button type="button" class="link" id="preview-toggle" data-i18n="profile.preview"></button>
<span class="spacer"></span>
<button type="button" id="profile-cancel" data-i18n="profile.cancel"></button>
<button type="submit" class="primary" id="profile-save" data-i18n="profile.save"></button>
</div>
</form>
</dialog>
<!-- 全螢幕吱吱:還沒點時停在影片第一幀;簽到模式播完跳小卡,繼續吱吱模式可以一直點 -->
<div id="zhi-stage" class="zhi-stage" hidden>
<video id="zhi-video" src="/assets/media/zhizhi.mp4?v=__ASSET_VERSION__" poster="/assets/media/zhizhi-poster.webp?v=__ASSET_VERSION__"
playsinline webkit-playsinline preload="auto" disablepictureinpicture disableremoteplayback></video>
<div id="zhi-hint" class="zhi-hint" data-i18n="zhi.hint"></div>
<div id="zhi-count" class="zhi-count" hidden></div>
<button id="zhi-exit" class="zhi-exit" type="button"></button>
<!-- 繼續吱吱才有:打開後播完自動接著吱下一次 -->
<button id="zhi-auto" class="zhi-auto" type="button" aria-pressed="false" hidden></button>
</div>
<div id="toast" role="status" hidden></div>
</body>
</html>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

+12
View File
@@ -0,0 +1,12 @@
{
"name": "吱鼯計畫",
"short_name": "吱鼯計畫",
"start_url": "/",
"display": "standalone",
"background_color": "#1a0f06",
"theme_color": "#1a0f06",
"icons": [
{ "src": "/assets/icon-192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/assets/icon-512.png", "sizes": "512x512", "type": "image/png" }
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.
+381
View File
@@ -0,0 +1,381 @@
:root {
--bg: #1a0f06;
--panel: #27170a;
--panel-2: #35200e;
--line: #5a3a1c;
--text: #fff6ea;
--muted: #d9b993;
--accent: #ff8a1f;
--accent-ink: #2a1400;
--error: #ff7a7a;
--radius: 12px;
color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
background: var(--bg);
color: var(--text);
font: 16px/1.6 system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "Noto Sans JP", "Noto Sans KR",
"Microsoft JhengHei", "PingFang TC", sans-serif;
}
a { color: var(--accent); }
.layout { display: flex; min-height: 100vh; }
/* ---------- 側邊欄 ---------- */
#sidebar {
width: 280px;
flex-shrink: 0;
background: var(--panel);
border-right: 1px solid var(--line);
padding: 20px;
display: flex;
flex-direction: column;
gap: 20px;
}
.brand { display: flex; align-items: center; justify-content: space-between; }
.brand a { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none;
font-weight: 800; font-size: 20px; }
.brand .logo { border-radius: 8px; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text small { font-size: 12px; font-weight: 500; color: var(--accent); }
#sidebar-body { display: flex; flex-direction: column; gap: 24px; flex: 1; }
#sidebar h2 { font-size: 18px; margin: 0 0 4px; }
form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
input, textarea, select {
font: inherit;
color: var(--text);
background: var(--panel-2);
border: 1px solid var(--line);
border-radius: 8px;
padding: 10px 12px;
width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
#code { letter-spacing: .4em; font-size: 20px; text-align: center; }
textarea { resize: vertical; min-height: 120px; }
button, .button {
font: inherit;
cursor: pointer;
border: 1px solid var(--line);
background: var(--panel-2);
color: var(--text);
border-radius: 999px;
padding: 9px 20px;
text-decoration: none;
display: inline-flex;
align-items: center;
justify-content: center;
}
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
button.link { background: none; border: none; padding: 0; color: var(--accent); border-radius: 0; }
button.link:disabled { color: var(--muted); }
.icon-btn { padding: 4px 10px; border-radius: 8px; font-size: 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.error { color: var(--error); font-size: 14px; margin: 0; }
#me-box { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.me-name { font-size: 20px; font-weight: 700; word-break: break-word; }
.me-nav { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 12px; }
.me-nav a { text-decoration: none; }
.avatar { border-radius: 50%; object-fit: cover; background: var(--panel-2); width: 96px; height: 96px; }
.avatar.large { width: 160px; height: 160px; }
.beta { font-size: 12px; font-weight: 600; color: var(--muted); }
/* UID 與稱號:管理員預設黃底(和 server/app/titles.py TIER_COLORS 一致);
管理員指定的顏色由 app.js 直接寫在 style 上 */
.uid-wrap { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.profile .uid-wrap { justify-content: center; }
.uid { color: var(--muted); font-variant-numeric: tabular-nums; }
.uid.badge, .title-badge {
display: inline-block;
font-weight: 700;
padding: 2px 10px;
border-radius: 8px;
margin-top: 2px;
}
.uid.tier-admin, .title-badge.tier-admin { background: #ffd166; color: #2a1400; }
/* 管理員在個人頁設定稱號的表單 */
.title-form {
width: 100%;
text-align: left;
margin-top: 20px;
padding: 16px 20px;
background: var(--panel);
border: 1px dashed var(--accent);
border-radius: var(--radius);
}
.title-form h2 { font-size: 16px; margin: 0; }
.title-form .row { align-items: flex-end; flex-wrap: nowrap; }
.title-form .grow { flex: 1; min-width: 0; }
.title-form input[type=color] { width: 64px; height: 44px; padding: 4px; cursor: pointer; }
.lang { margin-top: auto; }
/* ---------- 主畫面 ---------- */
#main { flex: 1; padding: 40px 24px; display: flex; justify-content: center; }
#view-checkin, #view-user, #view-upload, #view-review { width: 100%; max-width: 560px; }
#view-upload h1, #view-review h1 { font-size: 24px; margin: 0 0 8px; }
#view-upload h2 { font-size: 18px; margin: 28px 0 12px; }
.center { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.center-text { text-align: center; }
.big-logo { width: 120px; height: 120px; border-radius: 28%; margin-top: 8vh; box-shadow: 0 16px 48px #ff8a1f44; }
.big-mark { font-size: 64px; font-weight: 900; letter-spacing: .08em; color: var(--accent); line-height: 1.2; }
.tagline { font-size: 22px; font-weight: 700; margin: 0; }
/* 「等等再吱」之後留在頁面上的入口:影片第一幀的縮圖,點了重新打開全螢幕 */
.zhi-open {
position: relative;
width: 180px;
aspect-ratio: 9 / 16;
margin-top: 4vh;
padding: 0;
overflow: hidden;
border-radius: 24px;
border: 3px solid var(--accent);
background: var(--panel-2);
box-shadow: 0 16px 48px #ff8a1f44;
transition: transform .15s;
}
.zhi-open img { width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; }
.zhi-open-label {
position: absolute;
left: 0; right: 0; bottom: 0;
padding: 24px 0 12px;
background: linear-gradient(transparent, #000c 70%);
color: #fff;
font-size: 22px;
font-weight: 900;
letter-spacing: .1em;
}
.zhi-open:hover { transform: scale(1.04); }
.zhi-open:active { transform: scale(.97); }
/* ---------- 全螢幕吱吱 ---------- */
body.zhi-on { overflow: hidden; }
.zhi-stage {
position: fixed;
inset: 0;
z-index: 30;
overflow: hidden;
background: #1a0f06;
cursor: pointer;
user-select: none;
-webkit-user-select: none;
-webkit-tap-highlight-color: transparent;
touch-action: manipulation; /* 連點時不要觸發雙擊放大 */
}
/* 影片是直式的:寬螢幕上兩側用放大模糊的第一幀填滿 */
.zhi-stage::before {
content: "";
position: absolute;
inset: -40px;
background: url("/assets/media/zhizhi-poster.webp") center / cover;
filter: blur(28px) brightness(.55);
}
.zhi-stage video {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
pointer-events: none;
}
@media (min-aspect-ratio: 3/4) {
.zhi-stage video { object-fit: contain; }
}
.zhi-hint {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
white-space: nowrap;
pointer-events: none;
font-size: clamp(40px, 11vw, 96px);
font-weight: 900;
letter-spacing: .08em;
color: #fff;
-webkit-text-stroke: 2px #2a1400;
paint-order: stroke fill;
text-shadow: 0 4px 0 #ff8a1f, 0 10px 32px #000a;
animation: zhi-breathe 1.4s ease-in-out infinite;
}
.zhi-stage.playing .zhi-hint { display: none; }
@keyframes zhi-breathe {
0%, 100% { transform: translate(-50%, -50%) scale(1); }
50% { transform: translate(-50%, -50%) scale(1.08); }
}
.zhi-count, .zhi-exit {
position: absolute;
top: max(16px, env(safe-area-inset-top));
padding: 8px 18px;
border-radius: 999px;
border: 1px solid #ffffff33;
background: #1a0f06cc;
color: #fff;
font-weight: 700;
backdrop-filter: blur(6px);
}
.zhi-count { right: 16px; color: var(--accent); font-size: 18px; font-variant-numeric: tabular-nums; pointer-events: none; }
.zhi-count.bump { animation: zhi-bump .18s ease-out; }
@keyframes zhi-bump { 50% { transform: scale(1.18); } }
.zhi-exit { left: 16px; font-size: 15px; }
/* 全自動吱吱:中下方的開關 */
.zhi-auto {
position: absolute;
left: 50%;
bottom: max(28px, env(safe-area-inset-bottom));
transform: translateX(-50%);
white-space: nowrap;
padding: 12px 28px;
border-radius: 999px;
border: 2px solid var(--accent);
background: #1a0f06cc;
color: #fff;
font-size: 18px;
font-weight: 800;
letter-spacing: .05em;
backdrop-filter: blur(6px);
}
.zhi-auto.on { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 28px #ff8a1faa; }
/* 粒子:位置、方向、距離、顏色由 app.js 用 CSS 變數指定 */
.particle {
position: fixed;
left: var(--x);
top: var(--y);
width: var(--s);
height: var(--s);
border-radius: 50%;
background: var(--c);
pointer-events: none;
z-index: 40;
animation: burst var(--d, .9s) cubic-bezier(.12, .75, .3, 1) forwards;
}
.particle.digit {
width: auto;
height: auto;
background: none;
color: var(--c);
font-size: var(--s);
font-weight: 900;
line-height: 1;
text-shadow: 0 2px 6px #0008;
}
@keyframes burst {
from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
70% { opacity: 1; }
to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.3) rotate(var(--r)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
.particle { display: none; }
.zhi-hint, .zhi-count.bump { animation: none; }
}
.checkin-msg { font-size: 22px; font-weight: 700; margin: 0; }
.card-img { width: 100%; height: auto; border-radius: 16px; box-shadow: 0 12px 40px #0008; background: var(--panel); }
.stats { color: var(--muted); margin: 0; font-size: 15px; }
.actions { justify-content: center; }
/* ---------- 投稿 / 審核 ---------- */
.upload-bar { margin-top: 16px; }
.upload-bar label.button { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 700; }
.upload-bar label.button.busy { opacity: .5; pointer-events: none; }
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.sub-item { position: relative; border-radius: 10px; overflow: hidden; background: var(--panel-2); aspect-ratio: 1; }
.sub-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sub-status {
position: absolute;
left: 6px; bottom: 6px;
font-size: 12px;
font-weight: 700;
padding: 1px 8px;
border-radius: 999px;
background: #000b;
color: var(--text);
}
.sub-status.approved { background: #2f9e5a; color: #fff; }
.sub-status.rejected { background: #6b3a3a; color: #fff; }
.review-img { max-width: 100%; max-height: 60vh; border-radius: 12px; background: var(--panel); box-shadow: 0 12px 40px #0008; }
.review-meta { margin: 0; line-height: 1.9; }
#review-name { font-weight: 700; text-decoration: none; }
.profile { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.profile h1 { margin: 12px 0 0; font-size: 28px; word-break: break-word; }
.bio {
width: 100%;
text-align: left;
background: var(--panel);
border: 1px solid var(--line);
border-radius: var(--radius);
padding: 4px 20px;
margin-top: 16px;
overflow-wrap: anywhere;
}
.bio pre { overflow-x: auto; background: var(--panel-2); padding: 12px; border-radius: 8px; }
.bio code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.bio pre code { padding: 0; }
.bio blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.bio table { border-collapse: collapse; }
.bio th, .bio td { border: 1px solid var(--line); padding: 4px 8px; }
.bio.empty { color: var(--muted); padding: 16px 20px; }
/* ---------- 編輯個人資料 ---------- */
dialog {
width: min(560px, calc(100vw - 32px));
background: var(--panel);
color: var(--text);
border: 1px solid var(--line);
border-radius: 16px;
padding: 24px;
}
dialog::backdrop { background: #000a; }
dialog h2 { margin: 0 0 4px; }
.avatar-edit { display: flex; gap: 16px; align-items: center; }
.avatar-edit .button { margin-bottom: 6px; }
.preview { margin-top: 0; max-height: 300px; overflow-y: auto; }
.dialog-actions { margin-top: 8px; }
#toast {
position: fixed;
left: 50%;
bottom: 32px;
transform: translateX(-50%);
background: var(--panel-2);
border: 1px solid var(--line);
padding: 10px 20px;
border-radius: 999px;
box-shadow: 0 8px 24px #0008;
z-index: 50;
}
.only-mobile { display: none; }
/* ---------- 手機:側欄收到上方 ---------- */
@media (max-width: 760px) {
.layout { flex-direction: column; }
#sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); padding: 12px 16px; gap: 12px; }
.only-mobile { display: inline-flex; }
#sidebar:not(.open) #sidebar-body { display: none; }
#sidebar-body { padding-bottom: 8px; }
#main { padding: 24px 16px; }
.big-logo { margin-top: 4vh; }
.big-mark { font-size: 48px; }
}