diff --git a/.github/ui-preview/publish.mjs b/.github/ui-preview/publish.mjs
index afbfce8f7..deb1f15ec 100644
--- a/.github/ui-preview/publish.mjs
+++ b/.github/ui-preview/publish.mjs
@@ -174,7 +174,8 @@ async function publish() {
for (const s of m.scenes) {
if (!s.shots.length) continue;
md += `#### ${s.title}\n\n`;
- for (const x of s.shots) md += `
\n\n${x.caption}\n\n`;
+ // shown at its own size (they're taken at 2x), a full page no wider than 760
+ for (const x of s.shots) md += `
\n\n${x.caption}\n\n`;
}
if (m.errors?.length) md += `⚠️ 有 ${m.errors.length} 步没能照计划执行
\n\n${m.errors.map((e) => "- " + e).join("\n")}\n \n`;
await setBlock(md);
diff --git a/.github/ui-preview/record.mjs b/.github/ui-preview/record.mjs
index 12be22426..38616e825 100644
--- a/.github/ui-preview/record.mjs
+++ b/.github/ui-preview/record.mjs
@@ -230,16 +230,19 @@ async function runStep(page, step, scene) {
if (step.target) {
const b = await (await locate(page, step)).boundingBox();
if (b) {
- const m = 24;
- const x = Math.max(0, b.x - m), y = Math.max(0, b.y - m);
- clip = { x, y, width: Math.min(VIEW.width - x, b.width + 2 * m), height: Math.min(VIEW.height - y, b.height + 2 * m) };
+ // the target with room around it, never so small that a button
+ // is shown without where it is
+ const w = Math.min(VIEW.width, Math.max(560, b.width + 48)), h = Math.min(VIEW.height, Math.max(340, b.height + 48));
+ const x = Math.min(VIEW.width - w, Math.max(0, b.x + b.width / 2 - w / 2));
+ const y = Math.min(VIEW.height - h, Math.max(0, b.y + b.height / 2 - h / 2));
+ clip = { x, y, width: w, height: h };
}
}
await page.screenshot({ path: path.join(OUT, file), clip });
} finally {
await page.evaluate(() => document.querySelector("[data-ui-preview]")?.style.removeProperty("visibility"));
}
- scene.shots.push({ file, caption: step.caption || step.name || "" });
+ scene.shots.push({ file, caption: step.caption || step.name || "", width: 2 * (clip?.width ?? VIEW.width) });
break;
}
default: