From 60e0a1b856424c1d3e0900f7ead7da2580cd8f89 Mon Sep 17 00:00:00 2001 From: Lang Date: Wed, 14 Oct 2026 21:37:27 +0800 Subject: [PATCH] =?UTF-8?q?dashboard:=20merge=20log=20page=20into=20index?= =?UTF-8?q?=20(nav=20=E9=A6=96=E9=A1=B5/=E8=AF=8D=E6=9D=A1/=E8=AF=AD?= =?UTF-8?q?=E6=B3=95);=20session=20back-link=20->=20index?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- actions/build_dashboard.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/actions/build_dashboard.py b/actions/build_dashboard.py index c41ddb9..50dcb92 100644 --- a/actions/build_dashboard.py +++ b/actions/build_dashboard.py @@ -107,7 +107,7 @@ tr:last-child td{border-bottom:none} # 页头/页脚:banner 结构(参考 FRA 模板) NAV = [("index", "index.html", "首页"), ("items", "items.html", "词条"), - ("grammar", "grammar.html", "语法"), ("log", "log.html", "日志")] + ("grammar", "grammar.html", "语法")] COMMON_JS = r""" const esc = s => String(s ?? "").replace(/[&<>"]/g, c => ({"&":"&","<":"<",">":">",'"':"""}[c])); @@ -177,7 +177,7 @@ def render_md(text: str) -> str: def session_body(s: dict, files: list[tuple[str, str]]) -> str: - head = (f'

← 返回日志

' + head = (f'

← 返回首页

' f'

{esc(s["date"])} · {esc(s["type"]) or "session"}

') if not files: return head + '

没有对应的 logs/*.md 记录文件。

' @@ -220,6 +220,11 @@ BODY_INDEX = """
+ +

训练日志

+
+

等级变更历史

+
""" BODY_ITEMS = """ @@ -249,14 +254,6 @@ BODY_GRAMMAR = """
""" -BODY_LOG = """ -

训练日志

-
-

等级变更历史

-
-""" - - # ---------- 各页脚本 ---------- SCRIPT_INDEX = r""" @@ -365,15 +362,17 @@ def main() -> int: conn.close() OUT.mkdir(parents=True, exist_ok=True) + for old in OUT.glob("*"): # 清掉上次生成的页面,避免残留(如已并入首页的 log.html) + if old.suffix in (".html", ".js"): + old.unlink() (OUT / "data.js").write_text( "window.DATA = " + json.dumps(payload, ensure_ascii=False) + ";\n", encoding="utf-8") gen = payload["generated"] pages = { - "index.html": ("概览", "index", BODY_INDEX, SCRIPT_INDEX), + "index.html": ("概览", "index", BODY_INDEX, SCRIPT_INDEX + SCRIPT_LOG), "items.html": ("词条", "items", BODY_ITEMS, SCRIPT_ITEMS), - "grammar.html": ("语法修正", "grammar", BODY_GRAMMAR, SCRIPT_GRAMMAR), - "log.html": ("训练日志", "log", BODY_LOG, SCRIPT_LOG), + "grammar.html": ("语法", "grammar", BODY_GRAMMAR, SCRIPT_GRAMMAR), } for fname, (title, active, body, script) in pages.items(): (OUT / fname).write_text(html_page(title, active, body, script, gen), encoding="utf-8") @@ -387,7 +386,7 @@ def main() -> int: for p in sorted(logs_dir.glob(f"{date}*.md"))] if logs_dir.exists() else [] body = session_body(s, files) (OUT / f"session-{s['id']}.html").write_text( - html_page(f"{date} {s.get('type','')}", "log", body, "", gen), encoding="utf-8") + html_page(f"{date} {s.get('type','')}", "index", body, "", gen), encoding="utf-8") n += 1 print(f"HTML : {OUT.relative_to(ROOT)}/ ({len(pages)} 页 + {n} 会话详情 + data.js, "