37d88da4bc
- admin-preview-2026-09-22/ 20页新版后台HTML原型+截图+validation(UI05 交付) - app-preview-2026-09-22/ 截图/validation/check 脚本入库及小改 - admin-redesign-concept 概念图 - UI05 管理后台分析与新版设计说明、用户列表分页计划文档 - UI06 全端视觉统一实施方案(以两个 HTML 预览为唯一视觉基准) - services/api g4-sync-once 手动同步脚本 Co-Authored-By: Claude Code <noreply@anthropic.com>
6 lines
3.4 KiB
JavaScript
6 lines
3.4 KiB
JavaScript
const fs=require('fs'),path=require('path');const {chromium}=require(require.resolve('@playwright/test',{paths:[path.resolve(__dirname,'../../../apps/admin')]}));
|
|
(async()=>{const browser=await chromium.launch({headless:true});const page=await browser.newPage({viewport:{width:1440,height:1000}});const errors=[];page.on('pageerror',e=>errors.push(e.message));fs.mkdirSync(path.join(__dirname,'screenshots'),{recursive:true});const files=fs.readdirSync(__dirname).filter(x=>/^\d\d-.*\.html$/.test(x)).sort(),results=[];const url=file=>'file:///'+path.join(__dirname,file).replaceAll('\\','/');for(const file of files){await page.goto(url(file));await page.evaluate(()=>Promise.all([...document.images].map(i=>i.decode().catch(()=>{}))));await page.screenshot({path:path.join(__dirname,'screenshots',file.slice(0,2)+'.png'),fullPage:true});results.push({file,overflow:await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth),brokenImages:await page.evaluate(()=>[...document.images].filter(i=>!i.complete||!i.naturalWidth).length)})}
|
|
await page.goto(url('02-albums.html'));await page.locator('#albumSearch').fill('Product');if(await page.locator('.album').count()!==1)throw Error('Album search failed');await page.locator('.album-cover').click();await page.waitForURL('**#3');await page.locator('.photo-check').first().check();await page.locator('[data-action="batchHide"]').click();await page.locator('[data-action="confirm"]').click();await page.locator('[data-action="photoFilter:hidden"]').click();if(await page.locator('.photo-item').count()!==2)throw Error('Batch hide failed');await page.evaluate(()=>location.hash='10');await page.locator('#userSearch').fill('emma');if(await page.locator('.data-table tbody tr').count()!==1)throw Error('User search failed');await page.selectOption('#language','en');await page.waitForFunction(()=>document.documentElement.lang==='en');await page.goto(url('14-embed-editor.html'));const rect=await page.locator('#embedded').boundingBox();if(rect.width!==195||rect.height!==280)throw Error('Widget dimension mismatch');await page.locator('[data-action="collapseEmbed"]').click();await page.locator('[data-action="expandEmbed"]').click();await page.selectOption('#slotMode','v1');if(!await page.locator('#v1Fields').isVisible())throw Error('Legacy mode missing');await page.goto(url('06-watermark.html'));await page.locator('#wmText').fill('DEMO');if(await page.locator('#wmPreview').innerText()!=='DEMO')throw Error('Watermark preview mismatch');
|
|
const narrow=[];await page.setViewportSize({width:390,height:844});for(const file of ['02-albums.html','03-photos.html','10-users.html','14-embed-editor.html']){await page.goto(url(file));narrow.push({file,overflow:await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth)});await page.screenshot({path:path.join(__dirname,'screenshots','mobile-'+file.slice(0,2)+'.png'),fullPage:true})}
|
|
const result={date:'2026-09-22',scope:'Offline HTML only; production admin untouched',pages:results,narrow,errors,widget:{width:rect.width,height:rect.height},interactions:['album search','batch hide','visibility filter','account search','language','widget collapse','v1 mode','watermark preview']};fs.writeFileSync(path.join(__dirname,'validation.json'),JSON.stringify(result,null,2));console.log(JSON.stringify(result));await browser.close();if(errors.length||results.some(p=>p.overflow||p.brokenImages)||narrow.some(p=>p.overflow))process.exitCode=1})().catch(e=>{console.error(e);process.exit(1)});
|