线上 /about 白屏排查(§16):30 条路由 + 6 种环境里唯一可复现的缺陷是 webkit/chromium + prefers-reduced-motion:reduce ⇒ pageerror #418,main 内 14 个元素 opacity 恒 0(正常环境只有 3 个首屏以下的滚动入场项)。 根因:useReducedMotion 用 window.matchMedia 作 useState 初值 ⇒ SSR false、客户端首帧 true; scroll-reveal / template / page-transition 又用它决定 initial/variants/甚至早返回不同树结构, 与 SSR HTML 不一致;且 reduce 时 whileInView 被清空 ⇒ 元素停在 initial 的 opacity:0。 修法(结构恒定,减少动效改用「时长 0」表达): - hook 首帧恒 false,挂载后 effect 同步真实偏好; - ScrollReveal/StaggerReveal 的 initial/whileInView/variants 不再按 reduce 清空; - template.tsx 与 StaggerChildren 去掉早返回裸结构,改空 variants。 回归守卫 e2e/reduced-motion-hydration.spec.ts(/about 与 /):断言 reduce 自证生效、 无 hydration 错误、h1 与末段标题 opacity=1。变异验证:hook 改回 matchMedia 初值 ⇒ 2 红,恢复 ⇒ 2 绿。 另:runbook 明确禁止对 dist/_next/static 用 --delete(回访者旧 HTML 会引用上一代 chunk); 本轮已从备份 --ignore-existing 合并回旧代 101 个文件。复算:tsc/type-check:e2e 0、 jest 35 套件 462 例 0、check:visual 0、check:motion 0、视觉 chromium-desktop 25/25。
27 lines
1.6 KiB
JavaScript
27 lines
1.6 KiB
JavaScript
import { chromium } from 'playwright';
|
|
const url = process.argv[2] ?? 'https://www.novalon.cn/about';
|
|
const b = await chromium.launch();
|
|
const ctx = await b.newContext({ viewport: { width: 1280, height: 900 } });
|
|
const p = await ctx.newPage();
|
|
const consoleMsgs = [], pageErrors = [], failed = [];
|
|
p.on('console', (m) => { if (['error','warning'].includes(m.type())) consoleMsgs.push(`${m.type()}: ${m.text()}`.slice(0, 300)); });
|
|
p.on('pageerror', (e) => pageErrors.push(String(e).slice(0, 400)));
|
|
p.on('requestfailed', (r) => failed.push(`${r.failure()?.errorText} ${r.url()}`.slice(0, 220)));
|
|
const resp = await p.goto(url, { waitUntil: 'networkidle', timeout: 60000 }).catch((e) => { console.log('GOTO_ERR', e.message); return null; });
|
|
await p.waitForTimeout(2000);
|
|
const info = await p.evaluate(() => ({
|
|
title: document.title,
|
|
bodyTextLen: (document.body?.innerText ?? '').trim().length,
|
|
bodyHtmlLen: document.body?.innerHTML.length ?? 0,
|
|
mainLen: document.querySelector('main')?.innerHTML.length ?? -1,
|
|
h1: [...document.querySelectorAll('h1')].map((h) => h.innerText.trim()).slice(0, 3),
|
|
nextErr: !!document.querySelector('nextjs-portal, [data-nextjs-dialog]'),
|
|
}));
|
|
await p.screenshot({ path: 'docs/acceptance/2026-10-20-prod-about/about-live.png', fullPage: true });
|
|
console.log('status', resp?.status());
|
|
console.log(JSON.stringify(info, null, 1));
|
|
console.log('pageErrors', JSON.stringify(pageErrors, null, 1));
|
|
console.log('console', JSON.stringify(consoleMsgs.slice(0, 12), null, 1));
|
|
console.log('failedRequests', JSON.stringify(failed.slice(0, 12), null, 1));
|
|
await b.close();
|