| 1234567891011 |
- import fs from 'node:fs';
- import {connectRealAccountWebView} from '../../scripts/lib/real-account-webview.mjs';
- const {cdp}=await connectRealAccountWebView();
- try{
- const snapshot=await cdp.evaluate(async()=>{if(location.pathname!=='/login'||!document.querySelector('#login-refinement-preview'))throw Error('不在登录原型页');const clone=document.querySelector('app-mb-login-page').cloneNode(true);clone.querySelectorAll('input').forEach(x=>{x.removeAttribute('value');x.value=''});clone.querySelectorAll('script').forEach(x=>x.remove());clone.querySelectorAll('*').forEach(x=>[...x.attributes].filter(a=>/^on/i.test(a.name)).forEach(a=>x.removeAttribute(a.name)));const styles=[];for(const sheet of [...document.styleSheets]){if(sheet.ownerNode?.tagName==='STYLE')styles.push(sheet.ownerNode.textContent);else if(sheet.href&&new URL(sheet.href).origin===location.origin)styles.push(await(await fetch(sheet.href)).text())}return{markup:clone.outerHTML,css:styles.join('\n'),htmlAttributes:[...document.documentElement.attributes].filter(a=>['class','style','data-palette','data-accent'].includes(a.name)).map(a=>[a.name,a.value])}});
- const base='file:///E:/work/fmode-app/test-results/real-account-20261130/build-r2/project/www/browser/';
- const css=snapshot.css.replace(/url\((['"]?)\/(?!\/)/g,(_,q)=>'url('+q+base);
- const attrs=snapshot.htmlAttributes.map(([k,v])=>k+'="'+v.replaceAll('&','&').replaceAll('"','"')+'"').join(' ');
- const file='prototypes/login-refinement-20261130/index.html';
- fs.writeFileSync(file,'<!doctype html><html lang="zh-CN" '+attrs+'><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><meta name="description" content="初始登录页静态布局原型,不发送验证码"><base href="'+base+'"><title>飞马SI · 初始登录布局预览</title><style>'+css+'</style></head><body>'+snapshot.markup+'</body></html>');console.log('已保存无脚本、无登录请求的静态布局原型');
- }finally{cdp.close()}
|