400 lines
18 KiB
Python
400 lines
18 KiB
Python
#!/usr/bin/env python3
|
||
"""读取 me/lang.db,生成多页静态仪表盘到 me/dashboard/。
|
||
|
||
页面:
|
||
index.html 四维等级 + 等级趋势 + 掌握概览
|
||
items.html 词条(单词/词组,过滤 + 搜索)
|
||
grammar.html 语法修正
|
||
log.html 训练日志 + 等级变更历史
|
||
|
||
共享页头/页脚(banner),共享数据 data.js。
|
||
|
||
用法:
|
||
python actions/build_dashboard.py
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import datetime as _dt
|
||
import html as _html
|
||
import json
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
ROOT = Path(__file__).resolve().parent.parent
|
||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||
import langdb # noqa: E402
|
||
|
||
OUT = langdb.ME / "dashboard"
|
||
|
||
|
||
# ---------- 样式 / 共享片段 ----------
|
||
|
||
CSS = r"""
|
||
*{box-sizing:border-box}
|
||
a{color:#7cc4ff;text-decoration:none}
|
||
a:hover{color:#b7dcff;text-decoration:underline}
|
||
a:visited{color:#7cc4ff} /* 避免浏览器默认紫色 */
|
||
body{font-family:system-ui,'Segoe UI',Roboto,'PingFang SC','Microsoft YaHei',sans-serif;
|
||
margin:0;background:#12141a;color:#e8e8ea;font-size:15px;line-height:1.55}
|
||
.wrap{max-width:1460px;margin:0 auto;padding:20px 20px 8px}
|
||
.banner{background:#0f1218;border-bottom:1px solid #232b38}
|
||
.banner.bot{border-bottom:0;border-top:1px solid #232b38;margin-top:26px}
|
||
.bwrap,.footwrap{max-width:1460px;margin:0 auto;padding:10px 20px;display:flex;align-items:center;gap:18px;font-size:13px;flex-wrap:wrap}
|
||
.brand{font-weight:700;color:#fff}
|
||
.banner .nav{display:flex;gap:16px;margin-left:auto;flex-wrap:wrap}
|
||
.banner .nav a{color:#9fb0c7;text-decoration:none;padding-bottom:2px}
|
||
.banner .nav a:hover{color:#fff;text-decoration:none}
|
||
.banner .nav a:visited{color:#9fb0c7}
|
||
.banner .nav a.on{color:#fff;font-weight:600;border-bottom:2px solid #4a90d9}
|
||
.banner .nav a.on:visited{color:#fff}
|
||
.footwrap{color:#8a94a6;font-size:12px;line-height:1.9;display:block}
|
||
h1{margin:.2em 0;font-size:24px}
|
||
h2{font-size:14px;text-transform:uppercase;letter-spacing:.7px;color:#9aa2b1;
|
||
margin:28px 0 12px;font-weight:600;border-bottom:1px solid #232b38;padding-bottom:.35em}
|
||
.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px}
|
||
.row{display:flex;gap:20px;flex-wrap:wrap;align-items:stretch;min-height:250px}
|
||
.row>.col{display:flex;flex-direction:column;min-width:0}
|
||
.row>.col>h2{margin-top:0}
|
||
.row>.col.grow{flex:3 1 0}
|
||
.row>.col.side{flex:1 1 0}
|
||
.row>.col>.chart,.row>.col>.cards.vert{flex:1;min-height:0}
|
||
.cards.vert{display:flex;flex-direction:column;gap:10px}
|
||
.cards.vert .card{flex:1;display:flex;align-items:center;gap:12px;padding:10px 16px}
|
||
.cards.vert .card .k{flex:1}
|
||
.cards.vert .card .v{margin:0;font-size:22px}
|
||
.card{background:#1b1e27;border:1px solid #2a2e3a;border-radius:10px;padding:16px}
|
||
.card .k{color:#9aa2b1;font-size:13px}
|
||
.card .v{font-size:28px;font-weight:700;margin-top:4px;color:#fff}
|
||
.card .c{color:#8a94a6;font-size:12px;margin-top:6px}
|
||
.chart{background:#1b1e27;border:1px solid #2a2e3a;border-radius:10px;padding:14px 12px 6px;display:flex;flex-direction:column}
|
||
.chart svg{flex:1;min-height:0;width:100%;height:100%;display:block}
|
||
.legend{display:flex;gap:16px;flex-wrap:wrap;font-size:13px;margin:0 6px 6px;color:#9aa2b1}
|
||
.legend i{display:inline-block;width:10px;height:10px;border-radius:2px;margin-right:5px;vertical-align:middle}
|
||
table{border-collapse:collapse;width:100%;font-size:13.5px;background:#1b1e27;border:1px solid #2a2e3a;border-radius:10px;overflow:hidden}
|
||
th,td{text-align:left;padding:8px 10px;border-bottom:1px solid #2a2e3a;vertical-align:top}
|
||
th{background:#1e222b;color:#9aa2b1;font-weight:600;position:sticky;top:0}
|
||
tr:last-child td{border-bottom:none}
|
||
.mono,code{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12.5px;color:#c9d1e2}
|
||
.badge{display:inline-block;padding:1px 8px;border-radius:999px;font-size:12px;font-weight:600}
|
||
.b-known{background:rgba(46,204,113,.15);color:#2ecc71}
|
||
.b-learning{background:rgba(241,196,15,.15);color:#f1c40f}
|
||
.b-fix{background:rgba(231,76,60,.15);color:#e74c3c}
|
||
.b-new{background:#2a2f3a;color:#9aa2b1}
|
||
.fx{color:#ffb4a8}
|
||
.toolbar{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:10px}
|
||
.toolbar button,.toolbar input{background:#1e222b;color:#e8e8ea;border:1px solid #2a2e3a;border-radius:8px;padding:6px 11px;font-size:13px;cursor:pointer}
|
||
.toolbar button.on{border-color:#4a90d9;color:#fff;background:#24314d}
|
||
.toolbar input{cursor:text;min-width:220px}
|
||
.muted{color:#8a94a6}
|
||
.wrapx{border-radius:10px;overflow:visible}
|
||
.md{background:#1b1e27;border:1px solid #2a2e3a;border-radius:10px;padding:4px 20px 18px;max-width:920px;margin:16px 0}
|
||
.md h1{font-size:22px;border-bottom:1px solid #232b38;padding-bottom:.3em}
|
||
.md h2{font-size:16px;text-transform:none;letter-spacing:0;color:#dfe5ee;border-bottom:1px solid #232b38;padding-bottom:.3em;margin-top:1.3em}
|
||
.md h3{font-size:14px;color:#c7d0de}
|
||
.md table{background:transparent;border:1px solid #2a2e3a;margin:10px 0}
|
||
.md th{background:#1e222b}
|
||
.md code{background:#0f1218;padding:1px 5px;border-radius:4px}
|
||
.md pre{background:#0f1218;border:1px solid #2a2e3a;border-radius:8px;padding:12px;font-size:12.5px;white-space:pre-wrap;word-break:break-word;overflow:visible}
|
||
.md pre code{background:none;padding:0}
|
||
.md ul{padding-left:22px}.md li{margin:2px 0}
|
||
.md a{color:#7cc4ff}.md a:visited{color:#7cc4ff}
|
||
.logdate{font-family:ui-monospace,Consolas,monospace;color:#9fd0ff;border-bottom:1px dashed #3f5a7d;padding-bottom:1px}
|
||
.logdate:hover{color:#cBE6ff;border-bottom-style:solid;text-decoration:none}
|
||
.md hr{border:0;border-top:1px solid #232b38;margin:18px 0}
|
||
.md blockquote{border-left:3px solid #2f5f96;margin:10px 0;padding:2px 14px;color:#b9c3d3}
|
||
.md p.pending{border:1px dashed #3f5a7d;border-radius:8px;padding:10px 14px;color:#7f8aa0;background:#141821;margin:8px 0}
|
||
"""
|
||
|
||
# 页头/页脚:banner 结构(参考 FRA 模板)
|
||
NAV = [("index", "index.html", "首页"), ("items", "items.html", "词条"),
|
||
("grammar", "grammar.html", "语法"), ("log", "log.html", "日志")]
|
||
|
||
COMMON_JS = r"""
|
||
const esc = s => String(s ?? "").replace(/[&<>"]/g, c => ({"&":"&","<":"<",">":">",'"':"""}[c]));
|
||
const badge = s => s ? `<span class="badge b-${s}">${s}</span>` : "";
|
||
const fx = s => s ? `<span class="fx mono">${esc(s)}</span>` : "";
|
||
"""
|
||
|
||
CHART_JS = r"""
|
||
// 等级趋势图(从训练日志的每次等级画线)
|
||
(function () {
|
||
const LV = {A1:1, A2:2, B1:3, B2:4, C1:5, C2:6};
|
||
const val = s => {
|
||
const m = String(s || "").trim().toUpperCase().match(/^([ABC])([12])(\+?)/);
|
||
return m ? LV[m[1] + m[2]] + (m[3] ? 0.5 : 0) : null;
|
||
};
|
||
const SK = [
|
||
{k:"listening", l:"听", c:"#4da3ff"}, {k:"speaking", l:"说", c:"#f1c40f"},
|
||
{k:"reading", l:"读", c:"#2ecc71"}, {k:"writing", l:"写", c:"#ff9f43"}];
|
||
const el = document.getElementById("chart");
|
||
const pts = DATA.log.slice().sort((a, b) => a.date < b.date ? -1 : 1)
|
||
.map(r => ({date: r.date, v: Object.fromEntries(SK.map(s => [s.k, val(r[s.k])]))}));
|
||
if (!pts.length || !pts.some(p => SK.some(s => p.v[s.k] != null))) {
|
||
el.innerHTML = '<div class="muted">暂无趋势数据</div>'; return;
|
||
}
|
||
const W = 640, H = 210, L = 42, R = 16, T = 12, B = 30, ymin = 0.7, ymax = 6.3;
|
||
const xs = i => L + (pts.length === 1 ? (W - L - R) / 2 : i * (W - L - R) / (pts.length - 1));
|
||
const ys = v => T + (ymax - v) * (H - T - B) / (ymax - ymin);
|
||
let g = "";
|
||
["A1","A2","B1","B2","C1","C2"].forEach((lab, i) => {
|
||
const y = ys(i + 1);
|
||
g += `<line x1="${L}" y1="${y}" x2="${W - R}" y2="${y}" stroke="#2a2e3a"/>`;
|
||
g += `<text x="${L - 8}" y="${y + 4}" fill="#9aa2b1" font-size="11" text-anchor="end">${lab}</text>`;
|
||
});
|
||
pts.forEach((p, i) => {
|
||
g += `<text x="${xs(i)}" y="${H - 14}" fill="#9aa2b1" font-size="11" text-anchor="middle">${p.date.slice(5)}</text>`;
|
||
});
|
||
SK.forEach(s => {
|
||
const seq = pts.map((p, i) => ({i, v: p.v[s.k]})).filter(o => o.v != null);
|
||
if (!seq.length) return;
|
||
if (seq.length > 1)
|
||
g += `<polyline fill="none" stroke="${s.c}" stroke-width="2" points="${seq.map(o => xs(o.i) + "," + ys(o.v)).join(" ")}"/>`;
|
||
seq.forEach(o => {
|
||
g += `<circle cx="${xs(o.i)}" cy="${ys(o.v)}" r="4" fill="${s.c}"><title>${s.l} ${o.v} · ${pts[o.i].date}</title></circle>`;
|
||
});
|
||
});
|
||
el.innerHTML = `<div class="legend">` + SK.map(s => `<span><i style="background:${s.c}"></i>${s.l}</span>`).join("") +
|
||
`</div><svg viewBox="0 0 ${W} ${H}" width="100%" height="100%" preserveAspectRatio="xMidYMid meet">${g}</svg>`;
|
||
})();
|
||
"""
|
||
|
||
|
||
# ---------- 服务端渲染小工具(会话详情页用) ----------
|
||
|
||
def esc(v) -> str:
|
||
return _html.escape("" if v is None else str(v))
|
||
|
||
|
||
def render_md(text: str) -> str:
|
||
"""Markdown → HTML。有 markdown 库就用,没有则降级为 <pre>。
|
||
未录入的格子(内容为 (待登记))渲染成可见的虚框。"""
|
||
try:
|
||
import markdown as _md
|
||
out = _md.markdown(text, extensions=["tables", "fenced_code"])
|
||
except ImportError:
|
||
out = "<pre>" + _html.escape(text) + "</pre>"
|
||
return out.replace("<p>(待登记)</p>", '<p class="pending">(待登记)</p>')
|
||
|
||
|
||
def session_body(s: dict, files: list[tuple[str, str]]) -> str:
|
||
head = (f'<p><a href="log.html">← 返回日志</a></p>'
|
||
f'<h1>{esc(s["date"])} · {esc(s["type"]) or "session"}</h1>')
|
||
if not files:
|
||
return head + '<p class="muted">没有对应的 logs/*.md 记录文件。</p>'
|
||
return head + "".join(f'<div class="md">{render_md(c)}</div>' for _, c in files)
|
||
|
||
|
||
def html_page(title: str, active: str, body: str, script: str, generated: str) -> str:
|
||
nav = "".join(
|
||
f'<a href="{href}"{" class=\"on\"" if key == active else ""}>{label}</a>'
|
||
for key, href, label in NAV)
|
||
return (
|
||
'<!doctype html><html lang="zh"><head><meta charset="utf-8">'
|
||
'<meta name="viewport" content="width=device-width, initial-scale=1">'
|
||
f'<title>{title} · Lang</title><style>{CSS}</style></head><body>'
|
||
'<header class="banner"><div class="bwrap">'
|
||
'<a class="brand" href="index.html">Lang · 我的学习状态</a>'
|
||
f'<nav class="nav">{nav}</nav></div></header>'
|
||
f'<main class="wrap">{body}</main>'
|
||
f'<footer class="banner bot"><div class="footwrap">'
|
||
f'数据源 <b>me/lang.db</b>(SQLite)· 由 actions/build_dashboard.py 生成 · {generated}'
|
||
'</div></footer>'
|
||
'<script src="data.js"></script>'
|
||
f'<script>{COMMON_JS}{script}</script>'
|
||
'</body></html>')
|
||
|
||
|
||
# ---------- 各页 body ----------
|
||
|
||
BODY_INDEX = """
|
||
<h2>掌握概览</h2>
|
||
<div class="cards" id="overview"></div>
|
||
|
||
<div class="row">
|
||
<div class="col grow">
|
||
<h2>等级趋势</h2>
|
||
<div class="chart" id="chart"></div>
|
||
</div>
|
||
<div class="col side">
|
||
<h2>四维等级</h2>
|
||
<div class="cards vert" id="skills"></div>
|
||
</div>
|
||
</div>
|
||
"""
|
||
|
||
BODY_ITEMS = """
|
||
<h1>词条 <span class="muted" style="font-size:14px">单词 / 词组</span></h1>
|
||
<div class="toolbar">
|
||
<button data-f="all" class="on">全部</button>
|
||
<button data-f="new">未学</button>
|
||
<button data-f="learning">学习中</button>
|
||
<button data-f="known">已掌握</button>
|
||
<button data-f="fix">待修正</button>
|
||
<input id="q" placeholder="搜索 item / 释义 / 上下文…">
|
||
<span id="count" class="muted"></span>
|
||
</div>
|
||
<div class="wrapx"><table id="items"></table></div>
|
||
<div class="toolbar" style="margin-top:10px">
|
||
<button id="prev">‹ 上一页</button>
|
||
<span id="pageinfo" class="muted"></span>
|
||
<button id="next">下一页 ›</button>
|
||
</div>
|
||
"""
|
||
|
||
BODY_GRAMMAR = """
|
||
<h1>语法</h1>
|
||
<h2>表达 / 功能语</h2>
|
||
<div class="wrapx"><table id="expr"></table></div>
|
||
<h2>语法修正 <span class="muted" style="font-size:14px">按问题登记、去重</span></h2>
|
||
<div class="wrapx"><table id="grammar"></table></div>
|
||
"""
|
||
|
||
BODY_LOG = """
|
||
<h1>训练日志</h1>
|
||
<div class="wrapx"><table id="log"></table></div>
|
||
<h2>等级变更历史</h2>
|
||
<div class="wrapx"><table id="history"></table></div>
|
||
"""
|
||
|
||
|
||
# ---------- 各页脚本 ----------
|
||
|
||
SCRIPT_INDEX = r"""
|
||
document.getElementById("skills").innerHTML = DATA.skills.map(s => `
|
||
<div class="card"><div class="k">${esc(s.name)}</div>
|
||
<div class="v">${esc(s.level)||"—"}</div></div>`).join("")
|
||
|| `<div class="muted">无数据</div>`;
|
||
const ov = DATA.overview;
|
||
const glyph = {word:"单词", phrase:"词组", expression:"表达", grammar:"语法"};
|
||
document.getElementById("overview").innerHTML = Object.keys(glyph).map(k => {
|
||
const o = ov[k];
|
||
const parts = k === "grammar"
|
||
? `待修正 ${o.fix} · 已克服 ${o.known||0}`
|
||
: `未学 ${o.new||0} · 学习中 ${o.learning} · 已掌握 ${o.known} · 待修正 ${o.fix}`;
|
||
return `<div class="card"><div class="k">${glyph[k]}</div>
|
||
<div class="v">${o.total}</div><div class="c">${parts}</div></div>`;
|
||
}).join("");
|
||
""" + CHART_JS
|
||
|
||
SCRIPT_ITEMS = r"""
|
||
const KIND = {word:"单词", phrase:"词组", expression:"表达"};
|
||
const PAGE = 200;
|
||
let currentFilter = "all", page = 0;
|
||
function filtered() {
|
||
const f = currentFilter, q = document.getElementById("q").value.trim().toLowerCase();
|
||
return DATA.items.filter(i =>
|
||
(i.kind === "word" || i.kind === "phrase") &&
|
||
(f === "all" || i.status === f) &&
|
||
(!q || (i.item + i.meaning + i.context + i.tags).toLowerCase().includes(q)));
|
||
}
|
||
function renderItems() {
|
||
const rows = filtered();
|
||
const pages = Math.max(1, Math.ceil(rows.length / PAGE));
|
||
page = Math.min(Math.max(0, page), pages - 1);
|
||
const slice = rows.slice(page * PAGE, (page + 1) * PAGE);
|
||
document.getElementById("items").innerHTML =
|
||
`<thead><tr><th>id</th><th>条目</th><th>等级</th><th>释义</th>
|
||
<th>上下文</th><th>状态</th></tr></thead><tbody>` +
|
||
(slice.map(i => `<tr>
|
||
<td class="mono">${esc(i.id)}</td>
|
||
<td><b>${esc(i.item)}</b></td><td>${esc(i.level)}</td>
|
||
<td>${esc(i.meaning)}</td><td class="muted">${esc(i.context)}</td>
|
||
<td>${badge(i.status)}</td></tr>`).join("")
|
||
|| `<tr><td colspan="6" class="muted">无</td></tr>`) + `</tbody>`;
|
||
document.getElementById("count").textContent = `共 ${rows.length} 条`;
|
||
document.getElementById("pageinfo").textContent = `第 ${page + 1} / ${pages} 页`;
|
||
}
|
||
document.querySelectorAll(".toolbar button[data-f]").forEach(b => b.onclick = () => {
|
||
currentFilter = b.dataset.f; page = 0;
|
||
document.querySelectorAll(".toolbar button[data-f]").forEach(x => x.classList.toggle("on", x === b));
|
||
renderItems();
|
||
});
|
||
document.getElementById("q").oninput = () => { page = 0; renderItems(); };
|
||
document.getElementById("prev").onclick = () => { page--; renderItems(); };
|
||
document.getElementById("next").onclick = () => { page++; renderItems(); };
|
||
renderItems();
|
||
"""
|
||
|
||
SCRIPT_GRAMMAR = r"""
|
||
const EXPR = DATA.items.filter(i => i.kind === "expression");
|
||
document.getElementById("expr").innerHTML =
|
||
`<thead><tr><th>id</th><th>条目</th><th>等级</th><th>释义</th><th>功能</th>
|
||
<th>上下文</th><th>状态</th><th>first</th><th>修正</th></tr></thead><tbody>` +
|
||
(EXPR.map(i => `<tr>
|
||
<td class="mono">${esc(i.id)}</td><td><b>${esc(i.item)}</b></td><td>${esc(i.level)}</td>
|
||
<td>${esc(i.meaning)}</td><td class="muted">${esc(i.function)}</td>
|
||
<td class="muted">${esc(i.context)}</td><td>${badge(i.status)}</td>
|
||
<td class="mono">${esc(i.first)}</td><td>${fx(i.fix)}</td></tr>`).join("") || "") + `</tbody>`;
|
||
document.getElementById("grammar").innerHTML =
|
||
`<thead><tr><th>id</th><th>类别</th><th>问题</th><th>正确规则</th><th>例子</th>
|
||
<th>状态</th><th>次数</th><th>最近</th><th>下次复习</th></tr></thead><tbody>` +
|
||
(DATA.grammar.map(g => `<tr>
|
||
<td class="mono">${esc(g.id)}</td><td>${esc(g.category)}</td>
|
||
<td>${esc(g.issue)}</td><td class="muted">${esc(g.rule)}</td>
|
||
<td>${fx(g.examples)}</td><td>${badge(g.status)}</td>
|
||
<td>${g.count}</td><td class="mono">${esc(g.last)}</td>
|
||
<td class="mono">${esc(g.next_review)}</td></tr>`).join("") || "") + `</tbody>`;
|
||
"""
|
||
|
||
SCRIPT_LOG = r"""
|
||
document.getElementById("log").innerHTML =
|
||
`<thead><tr><th>日期</th><th>类型</th><th>材料</th><th>听</th><th>说</th><th>读</th><th>写</th><th>备注</th></tr></thead><tbody>` +
|
||
(DATA.log.map(l => `<tr><td class="mono"><a class="logdate" href="session-${l.id}.html">${esc(l.date)}</a></td><td>${esc(l.type)}</td>
|
||
<td>${esc(l.material_level)}</td><td>${esc(l.listening)}</td><td>${esc(l.speaking)}</td>
|
||
<td>${esc(l.reading)}</td><td>${esc(l.writing)}</td>
|
||
<td class="muted">${esc(l.note)}</td></tr>`).join("") || "") + `</tbody>`;
|
||
document.getElementById("history").innerHTML =
|
||
`<thead><tr><th>日期</th><th>变更</th></tr></thead><tbody>` +
|
||
(DATA.history.map(h => `<tr><td class="mono">${esc(h.date)}</td>
|
||
<td>${esc(h.text)}</td></tr>`).join("") || "") + `</tbody>`;
|
||
"""
|
||
|
||
|
||
def main() -> int:
|
||
conn = langdb.connect()
|
||
data = langdb.export(conn)
|
||
payload = {
|
||
"generated": _dt.datetime.now().strftime("%Y-%m-%d %H:%M"),
|
||
"skills": data["skills"],
|
||
"overview": langdb.overview(conn),
|
||
"items": data["items"],
|
||
"grammar": data["grammar"],
|
||
"log": data["training_log"],
|
||
"history": data["level_history"],
|
||
}
|
||
conn.close()
|
||
|
||
OUT.mkdir(parents=True, exist_ok=True)
|
||
(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),
|
||
"items.html": ("词条", "items", BODY_ITEMS, SCRIPT_ITEMS),
|
||
"grammar.html": ("语法修正", "grammar", BODY_GRAMMAR, SCRIPT_GRAMMAR),
|
||
"log.html": ("训练日志", "log", BODY_LOG, SCRIPT_LOG),
|
||
}
|
||
for fname, (title, active, body, script) in pages.items():
|
||
(OUT / fname).write_text(html_page(title, active, body, script, gen), encoding="utf-8")
|
||
|
||
# 每个训练日志条目生成一个会话详情页
|
||
logs_dir = ROOT / "logs"
|
||
n = 0
|
||
for s in data["training_log"]:
|
||
date = s.get("date", "")
|
||
files = [(p.name, p.read_text(encoding="utf-8"))
|
||
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")
|
||
n += 1
|
||
|
||
print(f"HTML : {OUT.relative_to(ROOT)}/ ({len(pages)} 页 + {n} 会话详情 + data.js, "
|
||
f"{len(payload['items'])} items, {len(payload['grammar'])} grammar)")
|
||
return 0
|
||
|
||
|
||
if __name__ == "__main__":
|
||
sys.exit(main())
|