import { chromium } from 'playwright'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const ROOT = path.resolve(__dirname, '../..'); const OUT = '/Users/zhangxiang/Codes/Novalon/novalon-website/dogfood-ui-audit/2026-09-01T07-34-54/screenshots/verify'; import fs from 'node:fs'; fs.mkdirSync(OUT, { recursive: true }); const browser = await chromium.launch({ headless: true }); for (const r of ['/', '/about', '/products/erp']) { const ctx = await browser.newContext({ viewport: { width: 390, height: 844 } }); const p = await ctx.newPage(); await p.goto('http://localhost:3000' + r, { waitUntil: 'load' }); await p.waitForTimeout(1500); const slug = r === '/' ? 'home' : r.replace(/^\//, '').replace(/\//g, '__'); await p.screenshot({ path: path.join(OUT, `mobile-${slug}-fullpage.png`), fullPage: true }); // 滚到底再截首屏看底部 await p.evaluate(() => window.scrollTo(0, document.body.scrollHeight)); await p.waitForTimeout(500); await p.screenshot({ path: path.join(OUT, `mobile-${slug}-bottom.png`) }); console.log(`✓ mobile ${r} fullPage + bottom`); await ctx.close(); } await browser.close();