- Move served planet (animated webp, posters, 300 frames) and team mascots into src/assets/ - Use relative paths (assets/...) that work in file://, on the dev server and with docroot=src - Screenshot pipeline writes to src/assets/projects - Halo audit: report and measurements, ticker ring fix, shadow rules in DESIGN.md and spec.md
42 lines
2.2 KiB
JavaScript
42 lines
2.2 KiB
JavaScript
'use strict';
|
|
/* pageshots.cjs — обзорные снимки страницы (обе темы, 1440 / 390) для отчёта.
|
|
Полный прокрут: снимаются hero и портфолио, чтобы «до/после» не вырывалось из контекста. */
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { chromium } = require('playwright-core');
|
|
|
|
const URL = process.argv[2] || 'http://127.0.0.1:8791/src/index.html';
|
|
const OUT = path.join(__dirname, 'out', 'pages');
|
|
const EXEC = process.env.CHROME_EXE ||
|
|
'C:/Users/deeen/AppData/Local/ms-playwright/chromium_headless_shell-1223/chrome-headless-shell-win64/chrome-headless-shell.exe';
|
|
fs.mkdirSync(OUT, { recursive: true });
|
|
|
|
(async () => {
|
|
const browser = await chromium.launch({ executablePath: EXEC, args: ['--force-color-profile=srgb'] });
|
|
for (const theme of ['light', 'dark']) {
|
|
for (const vp of [{ w: 1440, h: 900 }, { w: 390, h: 844 }]) {
|
|
const ctx = await browser.newContext({ viewport: { width: vp.w, height: vp.h }, deviceScaleFactor: 1, reducedMotion: 'reduce' });
|
|
await ctx.addInitScript((t) => { try { localStorage.setItem('hm-theme', t); localStorage.setItem('hm-ticker', 'on'); localStorage.setItem('hm-cookie', 'accepted'); } catch (e) {} }, theme);
|
|
const page = await ctx.newPage();
|
|
await page.goto(URL, { waitUntil: 'load' });
|
|
await page.evaluate((t) => {
|
|
if (t === 'dark') document.documentElement.setAttribute('data-theme', 'dark');
|
|
else document.documentElement.removeAttribute('data-theme');
|
|
}, theme);
|
|
await page.evaluate(() => document.fonts.ready);
|
|
await page.waitForTimeout(700);
|
|
const hero = path.join(OUT, `${theme}-${vp.w}-hero.png`);
|
|
await page.screenshot({ path: hero, animations: 'disabled' });
|
|
const cases = page.locator('#cases');
|
|
if (await cases.count()) {
|
|
await cases.first().scrollIntoViewIfNeeded();
|
|
await page.waitForTimeout(500);
|
|
await page.screenshot({ path: path.join(OUT, `${theme}-${vp.w}-works.png`), animations: 'disabled' });
|
|
}
|
|
console.log(theme, vp.w, 'ok');
|
|
await ctx.close();
|
|
}
|
|
}
|
|
await browser.close();
|
|
})().catch((e) => { console.error(e); process.exit(1); });
|