feat(carrier): 航空母舰 PartDesign 有头创建工具包与初学者教学
- 新数据链 web/teaching/cases/carrier-partdesign:20 件零件(spec.json 唯一来源)、 内核建造器 parts/*.mjs、traces/FCStd/replay 全量产物;装配 20 插入 + 19 关节。 - 工具包 tools/carrier:catalog / preflight / create-part / create-assembly / create-all / list / self-test / README,按零件与装配拆分为独立工具。 - 共享驱动扩展 web/tools/cad-ui-rebuild:Loft/Pipe/Hole/Fillet/Chamfer/Mirrored/ LinearPattern 交互,Reversed 复选框补齐;装配 saveAssemblyBundle 先 Accept 再保存。 - 教学:lessons.mjs 新增 carrier 组(环境课 + 20 件 + 装配),suite-runner 增加 carrier-part/carrier-assembly,生成 carrier-toolkit.html 并接入 index 与控制台证据。 验证:20 件 210 步全部有头通过(P05 修复后 39640 m³;P06 回归 8/8); 装配 20/20 插入、19/19 关节、20 组件 0 畸形、0 mismatch;check:carrier、 check:reducer、check-console --live 全绿。 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
237
web/tools/teaching-console/build-carrier-page.mjs
Normal file
237
web/tools/teaching-console/build-carrier-page.mjs
Normal file
@@ -0,0 +1,237 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Generate web/teaching/carrier-toolkit.html — the beginner companion page for
|
||||
* the headed carrier toolkit (tools/carrier/).
|
||||
*
|
||||
* Deterministic: reads the toolkit catalog and the per-part UI step files, no
|
||||
* timestamps, so `--check` can byte-compare. Nothing is executed from here; the
|
||||
* page only shows what each tool would do and links to the teaching console.
|
||||
*
|
||||
* Usage:
|
||||
* node web/tools/teaching-console/build-carrier-page.mjs
|
||||
* node web/tools/teaching-console/build-carrier-page.mjs --check
|
||||
* Exit: 0 written/identical, 1 stale (--check), 2 bad arguments.
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { PROJECT_DIR, REPO_ROOT, groups, parts, stats } from "../../../tools/carrier/catalog.mjs";
|
||||
|
||||
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||
const DEFAULT_OUT = path.resolve(HERE, "../../teaching/carrier-toolkit.html");
|
||||
|
||||
/** Step kind → short Chinese badge, so a beginner knows what will be clicked. */
|
||||
const KIND_ZH = {
|
||||
sketch: "草图",
|
||||
feature: "特征",
|
||||
dressup: "修整",
|
||||
transform: "阵列/镜像",
|
||||
primitive: "图元",
|
||||
body: "Body",
|
||||
};
|
||||
|
||||
function readSteps(document) {
|
||||
try {
|
||||
const payload = JSON.parse(fs.readFileSync(path.join(PROJECT_DIR, "out/ui-steps", `${document}.json`), "utf8"));
|
||||
return payload.steps ?? [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function esc(text) {
|
||||
return String(text ?? "").replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ }[c]));
|
||||
}
|
||||
|
||||
function volumeText(volume) {
|
||||
return volume == null ? "—" : `${Math.round(volume).toLocaleString("en-US")} mm³`;
|
||||
}
|
||||
|
||||
function partCard(part) {
|
||||
const steps = readSteps(part.document);
|
||||
const rows = steps.map((step) => {
|
||||
const kind = KIND_ZH[step.kind] ?? step.kind ?? "";
|
||||
return `<li><span class="kind">${esc(kind)}</span><code>${esc(step.label)}</code></li>`;
|
||||
}).join("");
|
||||
const features = part.featureTypes?.length
|
||||
? ` · 特征 ${part.featureTypes.map(esc).join("、")}`
|
||||
: "";
|
||||
return `<article class="part" id="${esc(part.id)}">
|
||||
<div class="head"><h3>${esc(part.id)} · ${esc(part.title)}</h3><span class="pill">${part.steps} 步</span></div>
|
||||
<div class="meta"><code>${esc(part.document)}</code> · 记录体积 ${esc(volumeText(part.volume))}${features}</div>
|
||||
<ol class="steps">${rows}</ol>
|
||||
<pre class="cmd">cd "${esc(REPO_ROOT)}" && DISPLAY=:1 node tools/carrier/create-part.mjs ${esc(part.id)}</pre>
|
||||
<div class="links">
|
||||
<a href="console.html">在教学控制台运行</a>
|
||||
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
|
||||
</div>
|
||||
</article>`;
|
||||
}
|
||||
|
||||
function render() {
|
||||
const summary = stats();
|
||||
const all = parts();
|
||||
const sections = groups().map((group) => {
|
||||
const members = all.filter((part) => part.system === group.id);
|
||||
return `<section class="group" id="group-${esc(group.id)}">
|
||||
<h2>${esc(group.label)} <span class="muted small">${members.length} 件</span></h2>
|
||||
<div class="parts">${members.map(partCard).join("")}</div>
|
||||
</section>`;
|
||||
}).join("");
|
||||
|
||||
return `<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>航空母舰 · PartDesign 有头创建工具(初学者)</title>
|
||||
<style>
|
||||
:root{--bg:#0f1419;--panel:#17212b;--panel2:#1b2733;--line:#2a3a45;--text:#dbe6ee;--muted:#93a6b3;--accent:#73c6d4;--ok:#7fc98b;--warn:#e0b15c;--bad:#e58a8a;color-scheme:dark}
|
||||
*{box-sizing:border-box}
|
||||
body{margin:0;background:var(--bg);color:var(--text);font:15px/1.65 system-ui,-apple-system,"Segoe UI","Noto Sans CJK SC","Microsoft YaHei",sans-serif;overflow-wrap:break-word}
|
||||
a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}
|
||||
code,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
||||
code{background:#0b1117;border:1px solid var(--line);border-radius:4px;padding:.1em .35em;font-size:.9em}
|
||||
header.top{position:sticky;top:0;z-index:10;display:flex;gap:14px;align-items:center;padding:10px 18px;background:rgba(15,20,25,.94);border-bottom:1px solid var(--line);backdrop-filter:blur(6px)}
|
||||
header.top .brand{font-weight:650}
|
||||
header.top .spacer{flex:1}
|
||||
main{max-width:1180px;margin:0 auto;padding:18px}
|
||||
h1{font-size:22px;margin:6px 0}
|
||||
h2{font-size:17px;margin:26px 0 10px;border-bottom:1px solid var(--line);padding-bottom:6px}
|
||||
h3{font-size:15px;margin:0}
|
||||
.lead{color:#c6d6e2}
|
||||
.muted{color:var(--muted)}.small{font-size:12.5px}
|
||||
.card{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px 16px;margin:12px 0}
|
||||
.pill{background:var(--panel2);border:1px solid var(--line);border-radius:999px;padding:1px 9px;font-size:12px;color:var(--muted)}
|
||||
.parts{display:grid;grid-template-columns:repeat(auto-fill,minmax(330px,1fr));gap:12px}
|
||||
.part{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:12px 14px}
|
||||
.part .head{display:flex;gap:8px;align-items:center;justify-content:space-between}
|
||||
.part .meta{color:var(--muted);font-size:12.5px;margin:4px 0 8px}
|
||||
.steps{margin:6px 0 10px 18px;padding:0;font-size:13px}
|
||||
.steps li{margin:2px 0}
|
||||
.steps .kind{display:inline-block;min-width:52px;color:var(--muted);font-size:11.5px;letter-spacing:.02em}
|
||||
pre.cmd{background:#0b1117;border:1px solid var(--line);border-radius:8px;padding:8px 10px;font-size:12px;overflow:auto;white-space:pre-wrap;word-break:break-all}
|
||||
.links{display:flex;gap:12px;flex-wrap:wrap;font-size:13px;margin-top:8px}
|
||||
table{border-collapse:collapse;width:100%;font-size:13.5px}
|
||||
th,td{border-bottom:1px solid var(--line);padding:6px 8px;text-align:left;vertical-align:top}
|
||||
th{color:var(--muted);font-weight:500}
|
||||
.note{border-left:3px solid var(--warn);padding:8px 12px;background:#1d1a12;border-radius:0 8px 8px 0;margin:10px 0}
|
||||
@media (max-width:700px){.parts{grid-template-columns:1fr}main{padding:12px}}
|
||||
@media print{header.top,.links,pre.cmd{display:none!important}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header class="top"><span class="brand">航空母舰 · PartDesign 有头创建工具</span><span class="spacer"></span>
|
||||
<a href="index.html">教学中心</a><a href="console.html">教学控制台</a><a href="cases/carrier.html">旧版案例</a></header>
|
||||
<main>
|
||||
<h1>在真实界面里造一艘航空母舰</h1>
|
||||
<p class="lead">${summary.parts} 个 PartDesign 零件,${summary.steps} 个界面步骤,分 ${groups().length} 个系统;每件都在真实浏览器里从草图开始点出来,最后装配成整舰(${summary.parts} 个链接 + ${summary.parts - 1} 个固定关节)。舰长 333 m、甲板高 24 m,全部零件共用同一套舰体坐标。</p>
|
||||
|
||||
<div class="card">
|
||||
<h2 style="margin-top:0">先做三件事</h2>
|
||||
<ol>
|
||||
<li>构建前端:<code>cd web && npx vite build</code>(改过 <code>web/src</code> 之后必做)。</li>
|
||||
<li>检查环境:<code>node tools/carrier/create-part.mjs P01 --dry</code> —— 只看前置,不启动浏览器。</li>
|
||||
<li>建第一个零件:下面任意一张卡片里的命令,或直接打开<a href="console.html">教学控制台</a>点「开始」。</li>
|
||||
</ol>
|
||||
<p class="small muted">有头运行需要图形环境(<code>DISPLAY=:1</code>)与 Chrome。每次运行约 5–10 分钟,重型特征(甲板倒角、舰体放样)计算较久,界面会显示「计算中…」,等它结束即可。报告落在 <code>docs/current/carrier-partdesign-toolkit/runs/</code>,截图落在 <code>web/tools/carrier-partdesign-course/ui-stills/</code>。</p>
|
||||
</div>
|
||||
|
||||
<div class="note"><strong>判定怎么读:</strong>通过 = 每一步都点到、最终体积与构建记录一致;产品失败(exit 1)= 界面建出的体积不对或有步骤没完成;前置失败(exit 2)= dist/内核/Chrome/DISPLAY/步骤文件缺失,此时还没开始点,不算产品问题。</div>
|
||||
|
||||
<div class="note"><strong>零件在船上是什么样:</strong>每件都按舰体坐标建模(X 向舰首为 +,z=24 m 为飞行甲板面),所以单独打开是零件、装配后自动就位,插装位姿是单位矩阵。改一个零件的尺寸,装配结果跟着变——这正是教学里要讲的“零件与装配同源”。</div>
|
||||
|
||||
${sections}
|
||||
|
||||
<section class="group" id="assembly">
|
||||
<h2>装配 <span class="muted small">1 艘</span></h2>
|
||||
<article class="part">
|
||||
<div class="head"><h3>CarrierAssembly · ${summary.parts} 件合成整舰</h3><span class="pill">${summary.parts} 插入 / ${summary.parts - 1} 关节</span></div>
|
||||
<div class="meta">新建装配文档「航空母舰」,逐个装载并插入 ${summary.parts} 个零件链接,接地舰体,其余 ${summary.parts - 1} 件各建一个固定关节,最后求解并列出 BOM。</div>
|
||||
<pre class="cmd">cd "${esc(REPO_ROOT)}" && DISPLAY=:1 node tools/carrier/create-assembly.mjs</pre>
|
||||
<div class="links"><a href="console.html">在教学控制台运行</a><a href="cases/carrier.html">旧版案例(Part 工作台 20 件)</a></div>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="group" id="tools">
|
||||
<h2>这套工具本身</h2>
|
||||
<table>
|
||||
<thead><tr><th>命令</th><th>作用</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>node tools/carrier/list.mjs</code></td><td>列出 ${summary.parts} 个零件、系统分组、步数与记录体积</td></tr>
|
||||
<tr><td><code>node tools/carrier/create-part.mjs P02</code></td><td>有头重建一个零件(P 编号或 Document 名都行)</td></tr>
|
||||
<tr><td><code>node tools/carrier/create-part.mjs P02 --dry</code></td><td>只做前置检查,不启动浏览器</td></tr>
|
||||
<tr><td><code>node tools/carrier/create-part.mjs P02 --slow</code></td><td>放慢点击,适合边看边学</td></tr>
|
||||
<tr><td><code>node tools/carrier/create-all.mjs --group air-fighter</code></td><td>按系统串行重建</td></tr>
|
||||
<tr><td><code>node tools/carrier/create-all.mjs --all --keep-going</code></td><td>全部 ${summary.parts} 件,出错继续</td></tr>
|
||||
<tr><td><code>node tools/carrier/create-assembly.mjs --dry</code></td><td>装配前置检查(清单、回放、源文档、引擎)</td></tr>
|
||||
<tr><td><code>node tools/carrier/create-assembly.mjs</code></td><td>真实界面装配整舰</td></tr>
|
||||
<tr><td><code>node tools/carrier/self-test.mjs</code></td><td>无浏览器自测(目录、分组、参数校验、前置)</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="small muted">工具只做编排与前置检查;每一步的点击由共享引擎 <code>web/tools/cad-ui-rebuild/</code> 执行,构建记录来自 <code>web/teaching/cases/carrier-partdesign/out/replay/</code>,界面步骤来自 <code>web/tools/carrier-partdesign-course/out/ui-steps/</code>,装配清单来自 <code>assembly-spec.json</code>。文档一律写 OPFS,只有显式「下载」才落到本地。</p>
|
||||
</section>
|
||||
|
||||
<section class="group" id="troubleshooting">
|
||||
<h2>常见问题</h2>
|
||||
<table>
|
||||
<thead><tr><th>现象</th><th>原因与处理</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>退出码 2,日志里有「前置缺失」</td><td>dist、内核产物、Chrome、DISPLAY 或步骤文件缺失。照提示修,或用 <code>--dry</code> 看全部检查项。</td></tr>
|
||||
<tr><td>退出码 1,体积不一致</td><td>界面建出的几何与构建记录不同,是产品回归;报告里给出两边体积与相对误差。</td></tr>
|
||||
<tr><td>某一步停住不动</td><td>重型特征(甲板倒角、舰体放样)计算可达数十秒,状态栏显示「计算中…」。工具会等树里出现新对象再继续,不要手动刷新。</td></tr>
|
||||
<tr><td>看不到浏览器窗口</td><td>有头需要可用的 X 显示;在带图形界面的会话里用 <code>DISPLAY=:1</code> 启动。</td></tr>
|
||||
<tr><td>页面打开是空白/旧版本</td><td>先 <code>cd web && npx vite build</code>,工具会自动为构建好的 dist 起临时服务。</td></tr>
|
||||
<tr><td>装配插入失败,提示源文档缺失</td><td>先跑完对应零件(<code>create-part</code>),把 <code>out/FCStd/<Document>.FCStd</code> 准备好;<code>create-assembly --dry</code> 会列出缺哪几份。</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<p class="small muted" style="margin:26px 0 40px">本页由 <code>web/tools/teaching-console/build-carrier-page.mjs</code> 生成,请勿手改。</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
}
|
||||
|
||||
function main() {
|
||||
const argv = process.argv.slice(2);
|
||||
let check = false;
|
||||
let out = DEFAULT_OUT;
|
||||
for (let index = 0; index < argv.length; index += 1) {
|
||||
const arg = argv[index];
|
||||
if (arg === "--check") check = true;
|
||||
else if (arg === "--out") out = path.resolve(argv[++index] ?? DEFAULT_OUT);
|
||||
else if (arg === "--help" || arg === "-h") {
|
||||
console.log("node web/tools/teaching-console/build-carrier-page.mjs [--check] [--out <file>]");
|
||||
process.exit(0);
|
||||
} else {
|
||||
console.error(`未知参数:${arg}`);
|
||||
process.exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
const html = render();
|
||||
if (check) {
|
||||
let existing = "";
|
||||
try {
|
||||
existing = fs.readFileSync(out, "utf8");
|
||||
} catch {
|
||||
console.error(`FAIL --check:目标文件不存在 ${out}`);
|
||||
process.exit(1);
|
||||
}
|
||||
if (existing === html) {
|
||||
console.log("check: OK(carrier-toolkit.html 已是最新)");
|
||||
return;
|
||||
}
|
||||
let offset = 0;
|
||||
while (offset < existing.length && offset < html.length && existing[offset] === html[offset]) offset += 1;
|
||||
console.error(`FAIL --check:不一致(首个差异偏移 ${offset})`);
|
||||
process.exit(1);
|
||||
}
|
||||
fs.mkdirSync(path.dirname(out), { recursive: true });
|
||||
fs.writeFileSync(out, html);
|
||||
console.log(`written ${path.relative(REPO_ROOT, out)} (${(Buffer.byteLength(html) / 1024).toFixed(0)} KB)`);
|
||||
}
|
||||
|
||||
main();
|
||||
99
web/tools/teaching-console/check-carrier-page.mjs
Normal file
99
web/tools/teaching-console/check-carrier-page.mjs
Normal file
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Browser gate for the beginner page web/teaching/carrier-toolkit.html.
|
||||
*
|
||||
* Opens the generated page over file:// (it must be self-contained and readable
|
||||
* with no server) and asserts: 20 part cards, every system section present,
|
||||
* copyable commands and links to the console / old case / hub, no template
|
||||
* leakage, no pageerror/console/request failures, and zero horizontal overflow
|
||||
* at 1440×900 and 390×844.
|
||||
*
|
||||
* Prerequisite: playwright resolvable from web/node_modules.
|
||||
* Exit: 0 pass / 1 page problem / 2 prerequisite missing.
|
||||
*
|
||||
* Usage: node web/tools/teaching-console/check-carrier-page.mjs
|
||||
*/
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { createRequire } from "node:module";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||
const REPO = path.resolve(HERE, "../../..");
|
||||
const require = createRequire(path.join(REPO, "web/package.json"));
|
||||
const PAGE = path.join(REPO, "web/teaching/carrier-toolkit.html");
|
||||
|
||||
const failures = [];
|
||||
const note = (message) => { failures.push(message); console.error(`FAIL ${message}`); };
|
||||
|
||||
let chromium;
|
||||
try {
|
||||
({ chromium } = require("playwright"));
|
||||
} catch {
|
||||
console.error("前置缺失:web/node_modules 下没有 playwright");
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const VIEWPORTS = [{ width: 1440, height: 900 }, { width: 390, height: 844 }];
|
||||
|
||||
const browser = await chromium.launch({ headless: true, args: ["--no-sandbox", "--disable-dev-shm-usage"] });
|
||||
const page = await browser.newPage({ viewport: VIEWPORTS[0] });
|
||||
const pageErrors = [];
|
||||
const consoleErrors = [];
|
||||
const failedRequests = [];
|
||||
page.on("pageerror", (error) => pageErrors.push(String(error.message ?? error)));
|
||||
page.on("console", (message) => { if (message.type() === "error") consoleErrors.push(message.text()); });
|
||||
page.on("requestfailed", (request) => failedRequests.push(`${request.url()} ${request.failure()?.errorText ?? ""}`));
|
||||
|
||||
const response = await page.goto(pathToFileURL(PAGE).href, { waitUntil: "load" });
|
||||
if (!response) note("file:// 打开页面失败(无 response)");
|
||||
|
||||
const dom = await page.evaluate(() => {
|
||||
const text = document.body.innerText;
|
||||
const partIds = [...document.querySelectorAll("article.part[id]")].map((node) => node.id);
|
||||
const hrefs = [...document.querySelectorAll("a[href]")].map((node) => node.getAttribute("href"));
|
||||
const commands = [...document.querySelectorAll("code")].map((node) => node.textContent).join("\n");
|
||||
return {
|
||||
partIds,
|
||||
groups: document.querySelectorAll("section.group").length,
|
||||
stepRows: document.querySelectorAll("ol.steps li").length,
|
||||
hrefs,
|
||||
hasConsole: hrefs.some((href) => /console\.html/.test(href)),
|
||||
hasCase: hrefs.some((href) => /cases\/carrier\.html/.test(href)),
|
||||
hasIndex: hrefs.some((href) => /(^|\/)index\.html$/.test(href)),
|
||||
command: /create-part\.mjs P\d{2}/.test(commands) && /create-assembly\.mjs/.test(commands)
|
||||
&& /create-all\.mjs/.test(commands),
|
||||
leakage: ["[object Object]", "undefined", "NaN", "${"].filter((token) => text.includes(token)),
|
||||
};
|
||||
});
|
||||
|
||||
const expectedIds = Array.from({ length: 20 }, (_, index) => `P${String(index + 1).padStart(2, "0")}`);
|
||||
const missing = expectedIds.filter((id) => !dom.partIds.includes(id));
|
||||
if (dom.partIds.length !== 20) note(`零件卡片 ${dom.partIds.length} 张,应为 20 张`);
|
||||
if (missing.length) note(`缺少零件卡片:${missing.join(", ")}`);
|
||||
// 12 system sections + assembly/tools/troubleshooting.
|
||||
if (dom.groups < 15) note(`分组区仅 ${dom.groups} 个,应至少 15 个(12 系统 + 装配/工具/排错)`);
|
||||
if (dom.stepRows < 200) note(`界面步骤条目仅 ${dom.stepRows} 条,应至少 200 条(记录 210 步)`);
|
||||
if (!dom.hasConsole) note("没有跳转教学控制台的链接");
|
||||
if (!dom.hasCase) note("没有跳转旧版案例(cases/carrier.html)的链接");
|
||||
if (!dom.hasIndex) note("没有返回 index.html 的链接");
|
||||
if (!dom.command) note("缺少可复制的 create-part / create-all / create-assembly 命令");
|
||||
for (const token of dom.leakage) note(`模板泄漏标记:${token}`);
|
||||
for (const error of pageErrors) note(`pageerror: ${error}`);
|
||||
for (const error of consoleErrors) note(`console: ${error}`);
|
||||
for (const error of failedRequests) note(`request: ${error}`);
|
||||
|
||||
for (const viewport of VIEWPORTS) {
|
||||
await page.setViewportSize(viewport);
|
||||
await page.waitForTimeout(120);
|
||||
const overflow = await page.evaluate(() => Math.max(0, document.documentElement.scrollWidth - window.innerWidth));
|
||||
if (overflow > 0) note(`${viewport.width}px: 横向溢出 ${overflow}px`);
|
||||
console.log(`${viewport.width}x${viewport.height}: overflow=${overflow}`);
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
if (failures.length) {
|
||||
console.error(`\ncarrier-toolkit.html 门禁失败:${failures.length} 项`);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`\ncarrier-toolkit.html 门禁通过:20 张零件卡片 / ${dom.groups} 个分组区 / ${dom.stepRows} 条步骤 / 双视口 0 溢出`);
|
||||
@@ -211,6 +211,24 @@ async function checkLive(browser) {
|
||||
if (reducer.evidence < 1) note("live reducer: 没有证据链接");
|
||||
console.log(`live reducer: verdict=${reducer.verdict} rows=${reducer.rows} evidence=${reducer.evidence}`);
|
||||
|
||||
// Carrier lesson: the environment lesson runs create-part --dry, which
|
||||
// exercises the whole carrier-part job kind (whitelist, argv, report
|
||||
// folding) in seconds instead of rebuilding a 13-step aircraft.
|
||||
await page.fill("#search", "航母");
|
||||
await page.click('#course-list button[data-id="lesson-carrier-environment"]');
|
||||
await page.click("#run");
|
||||
await page.waitForFunction(() => document.getElementById("terminal").textContent.includes("前置全部满足"), null, { timeout: 120000 });
|
||||
await page.waitForFunction(() => /通过|失败|运行失败|超时/.test(document.getElementById("verdict").textContent), null, { timeout: 180000 });
|
||||
const carrier = await page.evaluate(() => ({
|
||||
verdict: document.getElementById("verdict").textContent,
|
||||
rows: document.querySelectorAll("#results tbody tr").length,
|
||||
evidence: document.querySelectorAll("#evidence a").length,
|
||||
}));
|
||||
if (!/通过/.test(carrier.verdict)) note(`live carrier: 判定为「${carrier.verdict}」`);
|
||||
if (carrier.rows < 1) note("live carrier: 结果表没有零件行");
|
||||
if (carrier.evidence < 1) note("live carrier: 没有证据链接");
|
||||
console.log(`live carrier: verdict=${carrier.verdict} rows=${carrier.rows} evidence=${carrier.evidence}`);
|
||||
|
||||
// Mobile layout on the same live server.
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
*/
|
||||
|
||||
import { groups as reducerGroups, parts as reducerParts } from "../../../tools/reducer/catalog.mjs";
|
||||
import { groups as carrierGroups, parts as carrierParts } from "../../../tools/carrier/catalog.mjs";
|
||||
|
||||
export const GROUPS = [
|
||||
{ id: "basics", title: "准备:让环境可用", workbench: "系统", blurb: "先证明 dist、Chrome、显示和静态服务都就绪,再谈功能。" },
|
||||
{ id: "reducer", title: "二级减速器:逐件建模", workbench: "Reducer", blurb: "23 个零件各自一课,在真实界面里从头建出来;最后是装配课。" },
|
||||
{ id: "carrier", title: "航空母舰:逐件建模与装配", workbench: "Carrier", blurb: "20 个 PartDesign 零件(舰体、甲板、舰岛、舰载机…)各一课,再装配成整舰。" },
|
||||
{ id: "shell", title: "壳层与入口", workbench: "Shell", blurb: "COOP/COEP 隔离、工作台外壳、命令面板与偏好——所有功能的前提。" },
|
||||
{ id: "part", title: "Part:参数化零件", workbench: "Part", blurb: "图元、布尔、任务面板;最直观的建模入口。" },
|
||||
{ id: "partdesign", title: "PartDesign:实体特征", workbench: "PartDesign", blurb: "Body、草图、Pad 与边缘特征、Thickness。" },
|
||||
@@ -265,6 +267,57 @@ function volumeText(volume) {
|
||||
return volume == null ? "—" : `${Math.round(volume).toLocaleString("en-US")} mm³`;
|
||||
}
|
||||
|
||||
/**
|
||||
* The 20-part carrier curriculum, read from tools/carrier/catalog.mjs.
|
||||
*
|
||||
* Same shape as the reducer, with two differences that matter to a beginner:
|
||||
* every part lives in one shared ship coordinate system (so each one is shown
|
||||
* where it sits on the vessel), and the last lesson assembles all 20 into one
|
||||
* document with 19 fixed joints.
|
||||
*/
|
||||
function carrierLessons() {
|
||||
const parts = carrierParts();
|
||||
const byGroup = new Map(carrierGroups().map((group) => [group.id, group.label]));
|
||||
const intro = {
|
||||
id: "lesson-carrier-environment",
|
||||
groupId: "carrier",
|
||||
title: "航母 · 工具与前置自检(不启动浏览器)",
|
||||
level: "入门",
|
||||
durationMin: 1,
|
||||
summary: "先确认 20 件零件的界面步骤、构建记录与源文档齐全,再谈重建。本课用 dry run 只做前置检查,不打开 Chrome。",
|
||||
sees: ["零件清单、步数、记录体积与缺失项", "缺项时可直接执行的修复命令"],
|
||||
expect: "前置全部满足;缺项判「前置失败」,不算产品失败。",
|
||||
job: { kind: "carrier-part", partId: parts[0]?.id ?? "P01", dry: true },
|
||||
};
|
||||
const perPart = parts.map((part) => {
|
||||
const system = byGroup.get(part.system) ?? part.systemLabel ?? part.system;
|
||||
const features = part.featureTypes?.length ? `特征:${part.featureTypes.join("、")}。` : "";
|
||||
return {
|
||||
id: `lesson-carrier-${part.id.toLowerCase()}`,
|
||||
groupId: "carrier",
|
||||
title: `${part.id} · ${part.title}`,
|
||||
level: part.steps <= 4 ? "入门" : "进阶",
|
||||
durationMin: Math.max(3, Math.round(part.steps * 1.5) + 2),
|
||||
summary: `在真实界面里重建 ${part.document}(${system}):共 ${part.steps} 步。${features}完成后界面算出的体积应与构建记录 ${volumeText(part.volume)} 一致。`,
|
||||
sees: ["PartDesign 草图 → 特征 → 修整的逐步骤操作", "每步截图与最终体积对比"],
|
||||
expect: `create-part ${part.id} 判 pass(体积相对误差在引擎容差内)。`,
|
||||
job: { kind: "carrier-part", partId: part.id },
|
||||
};
|
||||
});
|
||||
const assembly = {
|
||||
id: "lesson-carrier-assembly",
|
||||
groupId: "carrier",
|
||||
title: "装配 · 20 件合成航空母舰",
|
||||
level: "进阶",
|
||||
durationMin: 20,
|
||||
summary: "新建装配文档 CarrierAssembly,按舰体坐标系逐个插入 20 个零件链接,接地舰体,为其余 19 件各建一个固定关节再求解。",
|
||||
sees: ["插入面板逐个装载源文档并保持统一位姿", "19 个固定关节与求解后的组件位形"],
|
||||
expect: "create-assembly 判 pass:插入 20/20、关节 19/19、求解组件无畸形、无失配。",
|
||||
job: { kind: "carrier-assembly" },
|
||||
};
|
||||
return [intro, ...perPart, assembly];
|
||||
}
|
||||
|
||||
/** The 23-part reducer curriculum comes from the toolkit catalog, not a copy. */
|
||||
function reducerLessons() {
|
||||
const parts = reducerParts();
|
||||
@@ -308,7 +361,7 @@ function reducerLessons() {
|
||||
}
|
||||
|
||||
export function buildLessons(catalog) {
|
||||
const lessons = [...CORE_LESSONS, ...reducerLessons(), ...chapterLessons(catalog), ...moduleLessons(catalog), ...crosscutLessons(catalog)];
|
||||
const lessons = [...CORE_LESSONS, ...reducerLessons(), ...carrierLessons(), ...chapterLessons(catalog), ...moduleLessons(catalog), ...crosscutLessons(catalog)];
|
||||
const seen = new Set();
|
||||
for (const lesson of lessons) {
|
||||
if (seen.has(lesson.id)) throw new Error(`课程 id 重复:${lesson.id}`);
|
||||
|
||||
Reference in New Issue
Block a user