feat: add realtime challenge client and local smoke test
CI / test (pull_request) Successful in 2m53s
PR合并自动部署 / release-check (pull_request) Successful in 1m34s
PR合并自动部署 / deploy (pull_request) Successful in 12s

This commit is contained in:
2026-08-09 03:08:01 +08:00
parent 821311f4ad
commit 1dd828609e
9 changed files with 872 additions and 7 deletions
+4 -6
View File
@@ -308,12 +308,8 @@ async function beginContest(contest) {
if (!requireAuth()) return;
try {
if (contest.kind === "realtime") {
const match = await api(`contests/${contest.slug}/matchmaking/`, { method: "POST", body: {} });
if (match.status === "waiting") {
showToast("已进入匹配队列,等待同赛道对手");
return;
}
renderAttempt(match.attempt);
await window.HuluRealtime.startRandom(contest);
return;
} else {
renderAttempt(await api(`contests/${contest.slug}/start/`, { method: "POST", body: {} }));
}
@@ -951,6 +947,7 @@ function bindUI() {
$("#auth-button").addEventListener("click", async () => {
if (!state.user) return openAuth();
await api("accounts/logout/", { method: "POST", body: {} });
window.HuluRealtime?.reset();
state.user = null;
updateUserUI();
showToast("已退出登录");
@@ -996,6 +993,7 @@ function bindUI() {
async function boot() {
bindUI();
window.HuluToolbox?.init();
window.HuluRealtime?.init();
renderSymbols();
await Promise.all([
loadUser(),