Complete all manual chapters with screenshots and command index
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -48,7 +48,9 @@ for (const chapter of chapters) {
|
||||
const text = inner.replace(/<[^>]+>/g, "").trim();
|
||||
const id = Number(level) === 1 ? chapter.id : `${chapter.id}-${slug(text)}`;
|
||||
return `<h${level} id="${esc(id)}">${inner}</h${level}>`;
|
||||
}).replace(/<img([^>]*?)>/g, (whole, attrs) => /loading=/.test(attrs) ? whole : `<img loading="lazy"${attrs}>`);
|
||||
}).replace(/<img([^>]*?)>/g, (whole, attrs) => /loading=/.test(attrs) ? whole : `<img loading="lazy"${attrs}>`)
|
||||
.replace(/<table>/g, '<div class="table-scroll"><table>')
|
||||
.replace(/<\/table>/g, '</table></div>');
|
||||
sections.push({ ...chapter, html: withIds });
|
||||
|
||||
const h2s = [...chapter.body.matchAll(/^## (.+)$/gm)].map(match => {
|
||||
@@ -72,7 +74,7 @@ for (const chapter of chapters) {
|
||||
const sidebarHtml = `<ol>${sidebar.map(chapter => `<li>
|
||||
<div class="chapter"><input type="checkbox" data-progress="${esc(chapter.id)}" aria-label="完成 ${esc(chapter.title)}" /><a href="#${esc(chapter.id)}">${esc(chapter.title)}</a></div>
|
||||
${chapter.sections.map(section => `<a class="sec" href="#${esc(section.id)}">${esc(section.title)}</a>`).join("")}
|
||||
</li>`).join("")}</ol>`;
|
||||
</li>`).join("")}<li><a href="#ch15">附录:命令索引</a></li></ol>`;
|
||||
|
||||
const statusLabel = { detailed: "精讲", overview: "覆盖", boundary: "边界", verified: "已验证", "fix-needed": "待修" };
|
||||
const moduleOptions = [...new Set(features.commands.map(item => item.module))].sort()
|
||||
|
||||
@@ -7,7 +7,7 @@ import path from "node:path";
|
||||
import { createHash } from "node:crypto";
|
||||
import { createRequire } from "node:module";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { listOpfsFiles, readOpfsFile } from "../carrier-course/lib/opfs.mjs";
|
||||
import { listOpfsFiles, readOpfsFile, seedOpfsFromBytes } from "../carrier-course/lib/opfs.mjs";
|
||||
|
||||
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||
const webRoot = path.resolve(here, "../..");
|
||||
@@ -124,6 +124,10 @@ async function runOnce() {
|
||||
await page.locator(action.selector).first().selectOption(action.label ? { label: action.label } : action.value);
|
||||
record({ action: "select", selector: action.selector, label: action.label ?? action.value });
|
||||
break;
|
||||
case "selectIndex":
|
||||
await page.locator(action.selector).first().selectOption({ index: action.index });
|
||||
record({ action: "selectIndex", selector: action.selector, index: action.index });
|
||||
break;
|
||||
case "press": await page.keyboard.press(action.key); record({ action: "press", key: action.key }); break;
|
||||
case "clickCanvas": {
|
||||
const target = page.locator(action.selector).first();
|
||||
@@ -157,6 +161,13 @@ async function runOnce() {
|
||||
await page.evaluate(action.script);
|
||||
record({ action: "eval" });
|
||||
break;
|
||||
case "seed": {
|
||||
const file = path.resolve(action.file);
|
||||
if (!fs.existsSync(file)) throw new Error(`seed fixture missing: ${file}`);
|
||||
await seedOpfsFromBytes(page, action.name ?? path.basename(file), fs.readFileSync(file));
|
||||
record({ action: "seed", file, name: action.name ?? path.basename(file) });
|
||||
break;
|
||||
}
|
||||
case "shot": await shot(action); break;
|
||||
case "save": await save(action); break;
|
||||
case "assertText": {
|
||||
@@ -169,6 +180,18 @@ async function runOnce() {
|
||||
await page.locator(action.selector).first().waitFor({ state: "visible", timeout: 30000 });
|
||||
record({ action: "assertVisible", selector: action.selector });
|
||||
break;
|
||||
case "waitOptions": {
|
||||
const locator = page.locator(action.selector).first();
|
||||
let count = 0;
|
||||
for (let attempt = 0; attempt < 80; attempt++) {
|
||||
count = await locator.locator("option").count();
|
||||
if (count >= (action.min ?? 1)) break;
|
||||
await page.waitForTimeout(500);
|
||||
}
|
||||
if (count < (action.min ?? 1)) throw new Error(`waitOptions failed: ${action.selector} ${count}`);
|
||||
record({ action: "waitOptions", selector: action.selector, count });
|
||||
break;
|
||||
}
|
||||
case "assertValue": {
|
||||
const value = await page.locator(action.selector).first().inputValue();
|
||||
if (String(value) !== String(action.value)) throw new Error(`assertValue failed: ${action.selector} ${value} != ${action.value}`);
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
th, td { border-bottom:1px solid var(--line); padding:5px 7px; text-align:left; vertical-align:top; }
|
||||
th { color:var(--accent); }
|
||||
code, pre { background:#0b1014; border:1px solid #22303a; border-radius:5px; }
|
||||
code { padding:1px 4px; font-size:12.5px; }
|
||||
pre { padding:10px; overflow:auto; }
|
||||
code { padding:1px 4px; font-size:12.5px; overflow-wrap:anywhere; }
|
||||
pre { padding:10px; overflow:auto; max-width:100%; white-space:pre-wrap; overflow-wrap:anywhere; }
|
||||
blockquote { border-left:3px solid var(--warn); margin:12px 0; padding:4px 12px; color:var(--warn); background:#1d1a1210; }
|
||||
.cmd { font-family:ui-monospace,monospace; font-size:12px; color:#9fd6de; }
|
||||
.badge { display:inline-block; border-radius:4px; padding:0 6px; font-size:11px; border:1px solid var(--line); }
|
||||
@@ -60,7 +60,7 @@
|
||||
nav.sidebar { position:fixed; z-index:35; top:53px; left:0; width:280px; background:#0d1318; transform:translateX(-100%); transition:transform .2s; }
|
||||
nav.sidebar.open { transform:translateX(0); }
|
||||
#menu-toggle { display:inline-block; }
|
||||
main { padding:18px 14px 60px; }
|
||||
main { padding:18px 14px 60px; overflow-x:clip; }
|
||||
header.top { gap:8px; padding:8px 10px; }
|
||||
header.top h1 { font-size:14px; max-width:34vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
||||
#search { width:auto; flex:1; min-width:0; margin-left:6px; }
|
||||
|
||||
Reference in New Issue
Block a user