From 4fdcdc4935d7685e519164fce5c3b22c4a4263e5 Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Wed, 7 Oct 2026 00:34:40 +0800 Subject: [PATCH] =?UTF-8?q?chore(scripts):=20=E6=97=8F=E8=B0=B1=E6=88=AA?= =?UTF-8?q?=E5=9B=BE=E5=B7=A5=E5=85=B7=E6=94=AF=E6=8C=81=E4=B8=A4=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E5=AD=90=E6=A0=91=EF=BC=88E2E=5FCAPTURE=5FMIN=5FNODES?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/capture-game-lineage-visual.mjs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/capture-game-lineage-visual.mjs b/scripts/capture-game-lineage-visual.mjs index 0dc01947f..8ad125e79 100644 --- a/scripts/capture-game-lineage-visual.mjs +++ b/scripts/capture-game-lineage-visual.mjs @@ -509,6 +509,9 @@ async function captureExistingUrls() { const lineageUrl = (process.env.E2E_CAPTURE_LINEAGE_URL ?? '').trim(); const themeUrl = (process.env.E2E_CAPTURE_THEME_URL ?? '').trim(); const selectTitle = (process.env.E2E_CAPTURE_SELECT_TITLE ?? '').trim(); + // 最小节点数:两节点的子树(例如「母版 → 一个衍生」)也要能截,默认 3。 + const minNodes = + Number.parseInt((process.env.E2E_CAPTURE_MIN_NODES ?? '').trim(), 10) || 3; // 视口可配:全树总览常常比 960 高,给个高的窗口才能真的「一眼看全」。 const sizeMatch = /^(\d{3,4})x(\d{3,4})$/u.exec( (process.env.E2E_CAPTURE_WINDOW ?? '').trim(), @@ -555,8 +558,8 @@ async function captureExistingUrls() { const page = await desktop.newPage(); await page.goto(lineageUrl, { waitUntil: 'commit', timeout: 120_000 }); await page.waitForFunction( - () => document.querySelectorAll('.game-lineage-node').length >= 3, - undefined, + (min) => document.querySelectorAll('.game-lineage-node').length >= min, + minNodes, { timeout: 120_000 }, ); await page.waitForTimeout(1400); @@ -564,7 +567,7 @@ async function captureExistingUrls() { const nodeCount = await page.locator('.game-lineage-node').count(); check( '截图模式:/games/lineage 已渲染多代节点', - nodeCount >= 3, + nodeCount >= minNodes, `nodes=${nodeCount} url=${lineageUrl}`, ); // 首屏视野契约(与 lineage 工具同口径):要么真的全览,要么按可读缩放下限 + 提示。 @@ -645,8 +648,8 @@ async function captureExistingUrls() { timeout: 120_000, }); await mobilePage.waitForFunction( - () => document.querySelectorAll('.game-lineage-node').length >= 3, - undefined, + (min) => document.querySelectorAll('.game-lineage-node').length >= min, + minNodes, { timeout: 120_000 }, ); await mobilePage.waitForTimeout(1400); @@ -668,7 +671,7 @@ async function captureExistingUrls() { })); check( '截图模式:窄屏下族谱画布可见、节点已渲染且页面不横向溢出', - narrow.canvas && narrow.nodes >= 3 && !narrow.overflow, + narrow.canvas && narrow.nodes >= minNodes && !narrow.overflow, `canvas=${narrow.canvas} nodes=${narrow.nodes} overflow=${narrow.overflow}`, ); await take(mobilePage, '03-lineage-narrow.png');