fix: complete v1.2 account and profile P0 fixes

This commit is contained in:
2026-08-10 00:12:53 +08:00
parent 587962f9c9
commit 97ca20413e
14 changed files with 346 additions and 12 deletions
+10 -3
View File
@@ -162,16 +162,22 @@ button { color: inherit; }
.editor-pane { background: #1d2721; color: white; }
.editor-pane label, .preview-pane > span { display: block; color: #9eaaa2; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.editor-pane textarea { width: 100%; height: 330px; margin-top: 22px; resize: none; border: 0; outline: 0; background: transparent; color: #dcefa1; font: 16px/1.8 "SFMono-Regular", Consolas, monospace; }
.preview-pane { display: flex; flex-direction: column; }
#latex-preview { margin: auto; max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: 18px 4px; font-size: 28px; line-height: 1.6; }
.preview-pane { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; }
#latex-preview { align-self: center; width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: 18px 4px; font-size: 28px; line-height: 1.6; }
#latex-preview .katex-display { margin: 0; overflow-x: auto; overflow-y: hidden; }
#latex-preview.latex-preview-error { color: #b84136; font: 14px/1.7 system-ui, sans-serif; white-space: normal; }
.preview-pane button { align-self: flex-end; }
.preview-pane button { align-self: end; justify-self: end; margin-top: 24px; }
.profile-panel { padding: 35px; }
.metric-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.metric { background: rgba(25,101,72,.06); border-radius: 14px; padding: 17px; }
.metric b, .metric span { display: block; }.metric b { font: 28px Georgia, serif; }.metric span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.profile-subtitle { margin: 30px 0 12px; font: 24px Georgia, serif; }.profile-game-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 9px; }.profile-game-list > div { padding: 13px; border-radius: 11px; background: #eef1eb; }.profile-game-list b, .profile-game-list span { display: block; }.profile-game-list span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.home-match-history[hidden] { display: none; }
.match-history-list { display: grid; gap: 10px; }
.match-history-item { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px; border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 13px; background: rgba(255,255,252,.8); }
.match-history-item.result-loss { border-left-color: #c05245; }.match-history-item.result-draw { border-left-color: #9a8455; }
.match-history-item > div, .match-history-item b, .match-history-item span, .match-history-item strong { display: block; }
.match-history-item > div:last-child { text-align: right; }.match-history-item span { margin-top: 5px; color: var(--muted); font-size: 11px; }.match-history-item strong { color: var(--green); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px; }
.tool-card {
min-height: 165px; border: 1px solid var(--line); border-radius: 18px; padding: 22px;
@@ -278,6 +284,7 @@ dialog::backdrop { background: rgba(17,25,20,.55); backdrop-filter: blur(5px); }
.hero { min-height: 500px; padding: 35px 25px; }.hero h1 { font-size: 44px; }.hero-actions { align-items: stretch; flex-direction: column; }
.section-heading { display: block; }.section-heading p { margin-top: 12px; }.spirit-grid, .content-grid, .editor-shell, .metric-grid, .tool-grid, .symbol-grid, .video-grid, .graph-shell, .game-card-grid, .calc-result-grid { grid-template-columns: 1fr; }
.content-grid { gap: 11px; }.editor-shell { min-height: 700px; }.page-title { padding-top: 42px; }.page-title h1 { font-size: 45px; }
.preview-pane { min-height: 320px; }.match-history-item { align-items: flex-start; flex-direction: column; }.match-history-item > div:last-child { text-align: left; }
.tool-card { min-height: 125px; }.workspace-heading, .map-heading { display: block; }.workspace-heading p { margin-top: 12px; }.tool-workspace { padding: 16px; }.calculator-controls { grid-template-columns: 1fr 1fr; }.calculator-display { min-height: 120px; padding: 18px; }.calculator-display output { font-size: 34px; }.calc-examples .primary-button { width: 100%; margin-left: 0; }.drawing-toolbar { align-items: stretch; }.drawing-toolbar .primary-button { width: 100%; margin-left: 0; }.canvas-stage canvas { width: 100%; min-width: 0; }
.math-games-section { margin-top: 45px; }.game-card { min-height: 260px; padding: 21px; }.game-card-controls { align-items: stretch; }.game-card-controls .primary-button { flex: 1; }.twenty-four-numbers { gap: 7px; }.twenty-four-numbers button { border-radius: 13px; font-size: 28px; }.sudoku-board input { font-size: clamp(13px, 4.5vw, 20px); }.sudoku-actions { display: grid; grid-template-columns: 1fr 1fr; }.game-keypad { gap: 5px; }
.challenge-panel { grid-template-columns: 1fr; padding: 20px; }.challenge-actions form { grid-template-columns: 1fr; }.challenge-actions .dark-button { width: 100%; }.challenge-code { width: 100%; padding: 14px 10px; font-size: 27px; }.realtime-status-line { display: grid; }.realtime-progress-panel { grid-template-columns: 1fr 1fr; }
+67 -2
View File
@@ -178,6 +178,7 @@ function updateUserUI() {
chip.append(avatar, name);
$("#auth-button").textContent = state.user ? "退出登录" : "登录 / 注册";
$("#admin-entry").hidden = !state.user?.is_staff;
if (!state.user) $("#home-match-history").hidden = true;
}
async function loadUser() {
@@ -188,6 +189,7 @@ async function loadUser() {
state.user = null;
}
updateUserUI();
await loadHomeMatchHistory();
}
function card({ meta, title, body, foot, action, onClick, disabled = false }) {
@@ -807,6 +809,15 @@ async function loadProfile() {
metrics.append(item);
});
root.append(heading, pet, metrics);
if (profile.recent_matches?.length) {
const matchTitle = document.createElement("h3");
matchTitle.className = "profile-subtitle";
matchTitle.textContent = "最近实时对局";
const matchList = document.createElement("div");
matchList.className = "match-history-list";
renderMatchHistory(matchList, profile.recent_matches);
root.append(matchTitle, matchList);
}
if (profile.recent_games?.length) {
const gameTitle = document.createElement("h3");
gameTitle.className = "profile-subtitle";
@@ -832,6 +843,51 @@ async function loadProfile() {
}
}
function renderMatchHistory(root, matches) {
root.replaceChildren(
...matches.map((match) => {
const item = document.createElement("article");
item.className = `match-history-item result-${match.result}`;
const summary = document.createElement("div");
const title = document.createElement("b");
title.textContent = `${match.contest} · 对手 ${match.opponent}`;
const time = document.createElement("span");
time.textContent = new Date(match.completed_at).toLocaleString();
summary.append(title, time);
const result = document.createElement("div");
const resultLabel = document.createElement("strong");
resultLabel.textContent =
match.result === "win" ? "胜利" : match.result === "loss" ? "惜败" : "平局";
const delta = document.createElement("span");
const sign = match.rating_delta > 0 ? "+" : "";
delta.textContent = `Rating ${sign}${match.rating_delta}${match.rating_after}`;
result.append(resultLabel, delta);
item.append(summary, result);
return item;
})
);
}
async function loadHomeMatchHistory() {
const section = $("#home-match-history");
if (!state.user) {
section.hidden = true;
return;
}
try {
const profile = await api("progression/me/");
if (!profile.recent_matches?.length) {
section.hidden = true;
return;
}
renderMatchHistory($("#home-match-list"), profile.recent_matches);
section.hidden = false;
} catch (error) {
section.hidden = true;
if (![401, 403].includes(error.status)) console.warn(error);
}
}
const MATH_SYMBOLS = [
["∑", "求和", "一组数或表达式的总和", "\\sum"],
["∏", "连乘", "一组数或表达式的乘积", "\\prod"],
@@ -1189,6 +1245,7 @@ function bindUI() {
window.HuluRealtime?.reset();
state.user = null;
updateUserUI();
if ($("#view-profile").classList.contains("active")) await loadProfile();
showToast("已退出登录");
});
$$("dialog .dialog-close").forEach((button) => button.addEventListener("click", () => button.closest("dialog").close()));
@@ -1209,7 +1266,11 @@ function bindUI() {
state.user = await api("accounts/login/", { method: "POST", body: Object.fromEntries(new FormData(event.target)) });
$("#auth-dialog").close();
updateUserUI();
await loadContent();
await Promise.all([
loadContent(),
loadHomeMatchHistory(),
$("#view-profile").classList.contains("active") ? loadProfile() : null,
]);
showToast("登录成功");
} catch (error) {
$("#auth-error").textContent = error.message;
@@ -1221,7 +1282,11 @@ function bindUI() {
state.user = await api("accounts/register/", { method: "POST", body: Object.fromEntries(new FormData(event.target)) });
$("#auth-dialog").close();
updateUserUI();
await loadContent();
await Promise.all([
loadContent(),
loadHomeMatchHistory(),
$("#view-profile").classList.contains("active") ? loadProfile() : null,
]);
showToast("账号和数学档案已建立");
} catch (error) {
$("#auth-error").textContent = error.message;
+5 -2
View File
@@ -350,8 +350,11 @@
result.append(outcome, score, timeLine, rating);
root.append(result);
// 刷新右上角用户 Rating 显示
if (typeof loadUser === "function") loadUser();
if (state.user) {
state.user.rating = match.result.rating_after;
updateUserUI();
}
loadUser();
const review = document.createElement("div");
review.className = "realtime-review";