Files
pear-admin-flask/scripts/compare_home.py
T
bwstudio 0ffc103e46 feat(plugins): 4 个业务插件代码 + 前台公开页面改造
plugins/navManager:导航 CRUD + 导航分类 CRUD(独立 blueprint)
plugins/friendManager:友情链接 CRUD
plugins/aboutManager:关于本站 CRUD
plugins/siteStats:访问统计主页 + JSON 接口 + /site/* GET 埋点 + nav 卡片点击埋点

applications/view/public/nav.py:导航聚合页 / 分类详情 / JSON 接口,支持 visit_count 注入
applications/view/public/about.py:关于本站公开页
applications/view/public/friend.py:友情链接公开页

templates/public/base.html:响应式首页(搜索框 / 分类抽屉 / 5 主题切换 / footer 隐私小字)
templates/public/index.html / category.html:卡片右下角访问次数
templates/public/about.html / friend.html:关于 + 友链前台页

docs/plugins-development.md:插件开发完整指南(生命周期 + 4 个示例 + FAQ + framework 迁移)

scripts/:探针与端到端验证脚本(probe_*/verify_*/test_*)
2026-09-06 18:18:06 +08:00

36 lines
1.4 KiB
Python

"""对比截图:本地手机端首页 vs 参考站首页(桌面 + 手机两套视口)"""
import os
import time
from playwright.sync_api import sync_playwright
OUT = r'D:\bwstudio\pear-admin-flask\scripts\screenshots\compare_home'
os.makedirs(OUT, exist_ok=True)
URLS = {
'local': 'http://192.168.1.10:5000/',
'ref': 'http://192.168.1.100/',
}
VIEWPORTS = {
'desktop': {'width': 1440, 'height': 900},
'mobile': {'width': 390, 'height': 844}, # iPhone 13
}
with sync_playwright() as pw:
browser = pw.chromium.launch(headless=True, args=['--no-sandbox', '--disable-gpu'])
for vp_name, vp in VIEWPORTS.items():
ctx = browser.new_context(viewport=vp, device_scale_factor=2,
user_agent='Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15' if vp_name=='mobile' else None)
page = ctx.new_page()
for label, url in URLS.items():
print(f'>> [{vp_name}] {label}: {url}')
try:
page.goto(url, wait_until='networkidle', timeout=20000)
time.sleep(2)
path = os.path.join(OUT, f'{vp_name}_{label}.png')
page.screenshot(path=path, full_page=True)
print(f' -> {path}')
except Exception as e:
print(f' ERR: {e}')
ctx.close()
browser.close()