37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
const pwPath = String.raw`C:\Users\12914\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\node_modules\playwright-core`;
|
|
const { chromium } = require(pwPath);
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
const base = String.raw`C:\Users\12914\Desktop\vscode\login-templates\v3-mobile`;
|
|
const out = path.join(base, 'screenshots');
|
|
if (!fs.existsSync(out)) fs.mkdirSync(out, {recursive: true});
|
|
|
|
const templates = [
|
|
['template1-bottomsheet.html', 't1-bottomsheet.png'],
|
|
['template2-gradient-card.html', 't2-gradient-card.png'],
|
|
['template3-clean-white.html', 't3-clean-white.png'],
|
|
['template4-fullscreen-dark.html', 't4-fullscreen-dark.png'],
|
|
['template5-playful-colorful.html', 't5-playful.png'],
|
|
];
|
|
|
|
(async () => {
|
|
const browser = await chromium.launch({ headless: true });
|
|
const ctx = await browser.newContext({
|
|
viewport: { width: 390, height: 844 },
|
|
deviceScaleFactor: 2,
|
|
});
|
|
const page = await ctx.newPage();
|
|
|
|
for (const [fname, oname] of templates) {
|
|
const url = 'file:///' + path.join(base, fname).replace(/\\/g, '/');
|
|
await page.goto(url, { waitUntil: 'networkidle', timeout: 15000 });
|
|
await page.waitForTimeout(1500);
|
|
await page.screenshot({ path: path.join(out, oname), fullPage: true });
|
|
console.log('OK: ' + oname);
|
|
}
|
|
|
|
await browser.close();
|
|
console.log('All done!');
|
|
})();
|