first commit

This commit is contained in:
2026-09-22 10:48:18 +08:00
commit 2006f7b4a4
20 changed files with 1877 additions and 0 deletions

149
app/static/css/app.css Normal file
View File

@@ -0,0 +1,149 @@
:root {
--ink: #12233d;
--ink-soft: #3a4a63;
--paper: #f3eee4;
--card: #fffdf8;
--line: #d8cfbf;
--teal: #1c6f63;
--teal-2: #2a9a86;
--amber: #c47b17;
--rose: #b44a4a;
--good: #2f7d4a;
--shadow: 0 18px 40px rgba(18, 35, 61, 0.08);
--font: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
font-family: var(--font);
color: var(--ink);
background:
radial-gradient(1200px 500px at -10% -20%, #e7f3ee 0%, transparent 50%),
radial-gradient(900px 400px at 110% 0%, #f8e9d2 0%, transparent 46%),
var(--paper);
min-height: 100vh;
}
a { color: var(--teal); }
.topbar {
display: flex; align-items: center; justify-content: space-between;
padding: 16px 28px;
border-bottom: 1px solid var(--line);
background: rgba(255,253,248,0.86);
backdrop-filter: blur(10px);
position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); }
.mark {
width: 36px; height: 36px; border-radius: 50%;
border: 2px solid var(--ink);
display: grid; place-items: center;
font-size: 11px; letter-spacing: 0.08em;
}
.brand b { display: block; font-size: 16px; }
.brand span { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 400; }
.topbar form { margin: 0; }
.ghost, .btn, .primary {
border: 1px solid var(--ink); background: transparent; color: var(--ink);
padding: 8px 14px; border-radius: 999px; cursor: pointer; font: inherit;
text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.primary { background: var(--ink); color: var(--paper); }
.btn.teal { background: var(--teal); border-color: var(--teal); color: white; }
.wrap { width: min(1180px, calc(100% - 40px)); margin: 28px auto 64px; }
.hero, .card, .login-card {
background: var(--card);
border: 1px solid var(--line);
border-radius: 22px;
box-shadow: var(--shadow);
}
.hero { padding: 28px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; }
.hero h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: 0.02em; }
.hero p { margin: 0; color: var(--ink-soft); line-height: 1.7; }
.drop {
border: 1.5px dashed var(--teal);
border-radius: 18px; padding: 22px; background: #f4fbf8;
}
.drop h3 { margin: 0 0 8px; }
.muted { color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
.list { margin-top: 22px; display: grid; gap: 10px; }
.item {
background: var(--card); border: 1px solid var(--line); border-radius: 14px;
padding: 14px 16px; display: flex; justify-content: space-between; align-items: center;
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); padding: 32px; }
.login-card h1 { margin: 8px 0 4px; }
label { display: block; font-size: 13px; margin: 14px 0 6px; color: var(--ink-soft); }
input[type=text], input[type=password], input[type=number], select {
width: 100%; padding: 10px 12px; border-radius: 10px;
border: 1px solid var(--line); font: inherit; background: white;
}
.err { color: var(--rose); font-size: 13px; margin-top: 8px; }
.layout { display: grid; grid-template-columns: 250px 1fr; gap: 22px; }
.rail {
background: var(--ink); color: #e8e2d6; border-radius: 22px; padding: 20px 16px;
height: fit-content; position: sticky; top: 88px;
}
.rail h2 { font-size: 14px; margin: 0 0 16px; font-weight: 600; }
.step {
display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 10px 8px;
border-radius: 12px; color: #c9c1b3; text-decoration: none;
}
.step b { display: block; color: inherit; font-size: 14px; }
.step span { display: block; font-size: 12px; opacity: 0.8; }
.dot {
width: 28px; height: 28px; border-radius: 50%; border: 1px solid #7d8796;
display: grid; place-items: center; font-size: 12px;
}
.step.on { background: rgba(255,255,255,0.06); color: white; }
.step.on .dot { background: var(--teal-2); border-color: var(--teal-2); color: white; }
.panel { padding: 24px 26px 30px; }
.panel h1 { margin: 0 0 6px; font-size: 26px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.kpi { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fbfaf6; }
.kpi em { display: block; font-style: normal; font-size: 12px; color: var(--ink-soft); }
.kpi strong { font-size: 22px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--ink-soft); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 6px; border-bottom: 1px solid #eee6d8; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.chip { background: #efe8da; border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.warn { background: #fff4e6; border: 1px solid #f1d2a3; color: #8a5a12; padding: 10px 12px; border-radius: 12px; margin: 8px 0; font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; font-size: 14px; }
.check input { margin-top: 3px; }
.actions { display: flex; gap: 10px; margin-top: 22px; }
.explain {
background: linear-gradient(180deg, #f7fbf9, #fff);
border: 1px solid #cfe3dc; border-radius: 16px; padding: 16px 18px; line-height: 1.7;
}
.route { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.route i {
font-style: normal; background: var(--ink); color: var(--paper);
border-radius: 999px; padding: 6px 10px; font-size: 12px;
}
.route i.alt { background: var(--teal); }
.bar-wrap { height: 10px; background: #efe8da; border-radius: 99px; overflow: hidden; }
.bar { height: 100%; background: var(--teal); }
.delta-up { color: var(--good); }
.delta-down { color: var(--rose); }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: #efe8da; }
.tag.mid { background: #f8e3bf; color: #8a5a12; }
.tag.high { background: #d8f0e5; color: #1c6f63; }
.drawer-bg {
position: fixed; inset: 0; background: rgba(18,35,61,0.35); display: none;
align-items: stretch; justify-content: flex-end; z-index: 20;
}
.drawer-bg.show { display: flex; }
.drawer {
width: min(560px, 100%); background: var(--card); padding: 22px;
overflow: auto; box-shadow: -20px 0 40px rgba(18,35,61,0.15);
}
.spark { width: 100%; height: 220px; }
.tiny { font-size: 12px; color: var(--ink-soft); }
.clickable { cursor: pointer; }
.clickable:hover { background: #f7f3ea; }
@media (max-width: 900px) {
.hero, .layout, .grid-2, .kpis { grid-template-columns: 1fr; }
.rail { position: static; }
}

112
app/static/js/app.js Normal file
View File

@@ -0,0 +1,112 @@
function closeDrawer() {
const el = document.getElementById("drawer");
if (el) el.classList.remove("show");
}
function sparkline(svg, exams, zs, xs, lastRank) {
const w = 520, h = 220, pad = 28;
const vals = [];
zs.forEach((z, i) => { if (z !== null && z !== undefined) vals.push(z); });
xs.forEach((z) => { if (z !== null && z !== undefined) vals.push(z); });
if (!vals.length) return;
const min = Math.min(...vals, -0.5) - 0.3;
const max = Math.max(...vals, 0.5) + 0.3;
const xAt = (i) => pad + (i * (w - pad * 2)) / Math.max(exams.length - 1, 1);
const yAt = (v) => pad + (max - v) * (h - pad * 2) / (max - min);
const pts = (arr) => arr.map((v, i) => v == null ? null : `${xAt(i)},${yAt(v)}`).filter(Boolean).join(" ");
let raw = "";
zs.forEach((v, i) => {
if (v == null) return;
raw += `<circle cx="${xAt(i)}" cy="${yAt(v)}" r="4.5" fill="#c47b17"></circle>`;
});
const pathXs = xs.map((v, i) => (v == null ? null : [xAt(i), yAt(v)])).filter(Boolean);
let d = "";
pathXs.forEach((p, i) => { d += (i === 0 ? `M${p[0]} ${p[1]}` : ` L${p[0]} ${p[1]}`); });
const labels = exams.map((e, i) => {
const short = String(e).replace("-总分", "").replace("高", "");
return `<text x="${xAt(i)}" y="${h - 6}" text-anchor="middle" font-size="10" fill="#3a4a63">${short}</text>`;
}).join("");
svg.setAttribute("viewBox", `0 0 ${w} ${h}`);
svg.innerHTML = `
<line x1="${pad}" y1="${yAt(0)}" x2="${w - pad}" y2="${yAt(0)}" stroke="#d8cfbf" stroke-dasharray="4 4"></line>
<path d="${d}" fill="none" stroke="#1c6f63" stroke-width="2.4"></path>
${raw}
${labels}
<text x="${pad}" y="16" font-size="11" fill="#3a4a63">标准分轨迹 · 橙点考试,绿线滤波估计</text>
`;
}
async function openStudent(aid, sid) {
const res = await fetch(`/analysis/${aid}/api/student/${encodeURIComponent(sid)}`);
if (!res.ok) return;
const s = await res.json();
const box = document.getElementById("drawer");
const body = document.getElementById("drawer-body");
const probs = Object.entries(s.probs || {}).map(([k, v]) => `${k}: ${(v * 100).toFixed(1)}%`).join(" ");
body.innerHTML = `
<div style="display:flex;justify-content:space-between;align-items:start">
<div>
<h2 style="margin:0">${s.name} <span class="tiny">${s.sid}</span></h2>
<div class="tiny">${s.class_name}班 · ${s.group} · ${s.status || "在籍"} · ${s.subjects || ""}</div>
</div>
<button class="ghost" onclick="closeDrawer()">关闭</button>
</div>
<p class="explain" style="margin-top:14px">
绿线是卡尔曼估计的稳定水平。如果橙点突然跳开绿线,系统会当成发挥波动,不会立刻改判断。
达线概率 ${probs || "—"}。
</p>
<svg class="spark" id="spark"></svg>
<table class="table">
<thead><tr><th>考试</th><th>分数</th><th>方向内名次</th><th>标准分</th><th>滤波</th></tr></thead>
<tbody id="spark-rows"></tbody>
</table>
`;
const rows = document.getElementById("spark-rows");
(s.z || []).forEach((z, i) => {
const exam = (window.HB_EXAMS || [])[i] || `第${i + 1}次`;
const score = s.scores ? s.scores[exam] : "";
const rank = (s.ranks || [])[i];
const kf = (s.kf_xs || [])[i];
rows.insertAdjacentHTML("beforeend", `<tr>
<td>${exam}</td><td>${score ?? "缺考"}</td><td>${rank ?? "—"}</td>
<td>${z == null ? "—" : z.toFixed(2)}</td>
<td>${kf == null ? "—" : kf.toFixed(2)}</td>
</tr>`);
});
sparkline(document.getElementById("spark"), window.HB_EXAMS || [], s.z || [], s.kf_xs || []);
box.classList.add("show");
}
async function openClass(aid, group, target, className) {
const url = `/analysis/${aid}/api/class?group=${encodeURIComponent(group)}&target=${encodeURIComponent(target)}&class_name=${encodeURIComponent(className)}`;
const res = await fetch(url);
if (!res.ok) return;
const data = await res.json();
const box = document.getElementById("drawer");
const body = document.getElementById("drawer-body");
const rows = data.students.map((s) => {
const p = ((s.probs || {})[target] || 0) * 100;
const tag = p >= 80 ? "high" : p >= 20 ? "mid" : "";
return `<tr class="clickable" onclick="openStudent(${aid}, '${s.sid}')">
<td>${s.name}</td><td>${s.status || ""}</td>
<td>${(s.ranks || []).slice(-1)[0] ?? "—"}</td>
<td><span class="tag ${tag}">${p.toFixed(1)}%</span></td>
</tr>`;
}).join("");
body.innerHTML = `
<div style="display:flex;justify-content:space-between">
<h2 style="margin:0">${className}班学生概率</h2>
<button class="ghost" onclick="closeDrawer()">关闭</button>
</div>
<p class="tiny">点击学生可看成绩轨迹。共 ${data.n} 人,下列按达线概率排序。</p>
<table class="table">
<thead><tr><th>姓名</th><th>学籍</th><th>最近名次</th><th>达线概率</th></tr></thead>
<tbody>${rows}</tbody>
</table>
`;
box.classList.add("show");
}
document.addEventListener("click", (e) => {
if (e.target.id === "drawer") closeDrawer();
});