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_*)
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
"""4 种主题切换 + 截图"""
|
|
import os
|
|
import time
|
|
from playwright.sync_api import sync_playwright
|
|
|
|
OUT = r'D:\bwstudio\pear-admin-flask\scripts\screenshots\themes'
|
|
os.makedirs(OUT, exist_ok=True)
|
|
|
|
THEMES = ['default', 'sunset', 'forest', 'dark']
|
|
|
|
with sync_playwright() as pw:
|
|
browser = pw.chromium.launch(headless=True, args=['--no-sandbox', '--disable-gpu'])
|
|
ctx = browser.new_context(viewport={'width':1440,'height':900})
|
|
page = ctx.new_page()
|
|
page.goto('http://192.168.1.10:5000/', wait_until='networkidle')
|
|
page.wait_for_timeout(800)
|
|
|
|
for theme in THEMES:
|
|
# 切换主题
|
|
page.evaluate(f'document.documentElement.setAttribute("data-theme", "{theme}"); localStorage.setItem("bw-theme", "{theme}");')
|
|
page.wait_for_timeout(500)
|
|
attr = page.evaluate('document.documentElement.getAttribute("data-theme")')
|
|
print(f' theme={theme} -> html data-theme={attr}')
|
|
path = os.path.join(OUT, f'{theme}.png')
|
|
page.screenshot(path=path, full_page=False)
|
|
print(f' -> {path}')
|
|
|
|
# 验证下拉菜单
|
|
page.evaluate('document.documentElement.setAttribute("data-theme", "default"); localStorage.removeItem("bw-theme");')
|
|
page.reload(wait_until='networkidle')
|
|
page.wait_for_timeout(800)
|
|
page.click('#theme-toggle')
|
|
page.wait_for_timeout(300)
|
|
# JS 强开菜单,避免点击被 document 监听关闭
|
|
page.evaluate('document.getElementById("theme-menu").classList.add("open")')
|
|
page.wait_for_timeout(500)
|
|
path = os.path.join(OUT, 'menu_open.png')
|
|
page.screenshot(path=path, full_page=False)
|
|
print(f' menu -> {path}')
|
|
|
|
browser.close() |