import { chromium } from 'playwright'; const base = 'http://localhost:4200'; const b = await chromium.launch({ channel: 'msedge' }); const ctx = await b.newContext({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true, userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Mobile/15E148 Safari/604.1' }); const p = await ctx.newPage(); const errs = []; p.on('pageerror', e => errs.push(e.message)); p.on('console', m => { if (m.type() === 'error') errs.push(m.text().slice(0, 140)); }); await p.goto(base + '/login'); await p.waitForTimeout(1000); await p.locator('input').nth(0).fill('13800000000'); await p.getByRole('button', { name: /获取验证码/ }).first().click(); await p.waitForTimeout(400); await p.locator('input').nth(1).fill('123456'); await p.getByRole('button', { name: /^登\s*录$/ }).first().click(); await p.waitForTimeout(3500); const routes = ['chat-index', 'contacts', 'projects', 'tasks', 'events', 'workbench', 'deliverables', 'mine']; const out = []; for (const r of routes) { await p.goto(`${base}/mobile/${r}`); await p.waitForTimeout(1800); const info = await p.evaluate(() => ({ len: document.body.innerText.trim().length, over: document.documentElement.scrollWidth > innerWidth + 1, text: document.body.innerText.slice(0, 40).replace(/\n/g, ' ') })); await p.screenshot({ path: `.tmp-shots/${r}.png` }); out.push([r, info.len, info.over, info.text]); } console.log(JSON.stringify({ out, errs: [...new Set(errs)].slice(0, 8) }, null, 1)); await b.close();