feat: add realtime challenge client and local smoke test
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user