Files
OneOS1.2/scripts/shot-h5-vehicle-all.mjs

63 lines
2.2 KiB
JavaScript

import puppeteer from 'puppeteer';
async function main() {
const browser = await puppeteer.launch({
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
await page.setViewport({ width: 1440, height: 960, deviceScaleFactor: 2 });
const url = 'http://localhost:51721/prototypes/oneos-v2?view=h5-vehicle';
console.log('Navigating to', url);
await page.goto(url, { waitUntil: 'networkidle2', timeout: 15000 });
await new Promise(r => setTimeout(r, 1500));
// 1. List View Screenshot
await page.screenshot({ path: '/Users/sylvawong/oneos1.2/.tmp-h5-vehicle-list.png', fullPage: false });
console.log('Saved List View screenshot');
// 2. Click Kanban Mode
const buttons = await page.$$('button');
for (const btn of buttons) {
const text = await page.evaluate(el => el.textContent, btn);
if (text && text.includes('2. 看板模式')) {
await btn.click();
break;
}
}
await new Promise(r => setTimeout(r, 1000));
await page.screenshot({ path: '/Users/sylvawong/oneos1.2/.tmp-h5-vehicle-kanban.png', fullPage: false });
console.log('Saved Kanban View screenshot');
// 3. Click Workbench Mode
for (const btn of buttons) {
const text = await page.evaluate(el => el.textContent, btn);
if (text && text.includes('3. 档案工作台')) {
await btn.click();
break;
}
}
await new Promise(r => setTimeout(r, 1000));
await page.screenshot({ path: '/Users/sylvawong/oneos1.2/.tmp-h5-vehicle-workbench.png', fullPage: false });
console.log('Saved Workbench View screenshot');
// 4. Click Dark Mode toggle
for (const btn of buttons) {
const text = await page.evaluate(el => el.textContent, btn);
if (text && (text.includes('暗色') || text.includes('深色'))) {
await btn.click();
break;
}
}
await new Promise(r => setTimeout(r, 1000));
await page.screenshot({ path: '/Users/sylvawong/oneos1.2/.tmp-h5-vehicle-dark.png', fullPage: false });
console.log('Saved Dark Mode screenshot');
await browser.close();
}
main().catch(console.error);