Files
platform-prototype/gen_screenshots.py
T
liuyunqinandClaude Opus 4.6 b8382c862f feat: 新增员工端应用主页与个人中心,优化应急三端页面
- 新增 employee-app/home/index.html 应用主页(功能按钮收起展开、体重管理、健康数据、智能监测24h曲线、膳食摄入)
- 新增 employee-app/profile/ 个人中心模块(16页:个人资料、头像、密码、手机号、紧急联系人、设置等)
- 修复 health-consult/index.html 返回导航逻辑
- 优化应急三端(驻场/操作/专业人员端)页面交互与截图
- 新增操作人员端、专业人员端 PRD 文档
- 更新 SITE_MAP 导航页
- 新增截图工具脚本(gen_screenshots.py、screenshot.js)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-29 09:55:33 +08:00

102 lines
4.4 KiB
Python

#!/usr/bin/env python3
"""
自动截图脚本 - 为三个端的所有页面生成截图
"""
import subprocess
import time
import os
from pathlib import Path
# 页面配置
PAGES = {
'onsite': {
'base_url': 'http://localhost:8000/emergency-app/onsite',
'pages': [
('workbench/index.html', 'screenshots/index.jpg'),
('workbench/work-order-detail-ongoing.html', 'screenshots/work-order-detail-ongoing.jpg'),
('workbench/work-order-detail.html', 'screenshots/work-order-detail.jpg'),
('workbench/serious-illness-list.html', 'screenshots/serious-illness-list.jpg'),
('workbench/serious-illness-detail-pending.html', 'screenshots/serious-illness-detail-pending.jpg'),
('workbench/serious-illness-detail-done.html', 'screenshots/serious-illness-detail-done.jpg'),
('knowledge/index.html', 'screenshots/knowledge-index.jpg'),
('knowledge/article-detail.html', 'screenshots/knowledge-article-detail.jpg'),
('profile/index.html', 'screenshots/profile-index.jpg'),
('profile/edit-profile.html', 'screenshots/edit-profile.jpg'),
('profile/change-pwd.html', 'screenshots/change-pwd.jpg'),
]
},
'operator': {
'base_url': 'http://localhost:8000/emergency-app/operator',
'pages': [
('workbench/index.html', 'screenshots/index.jpg'),
('workbench/emergency-chat-ongoing.html', 'screenshots/emergency-chat-ongoing.jpg'),
('workbench/emergency-chat-done.html', 'screenshots/emergency-chat-done.jpg'),
('workbench/work-order-detail.html', 'screenshots/work-order-detail.jpg'),
('workbench/serious-illness-detail-pending.html', 'screenshots/serious-illness-detail-pending.jpg'),
('knowledge/index.html', 'screenshots/knowledge-index.jpg'),
('knowledge/article-detail.html', 'screenshots/knowledge-article-detail.jpg'),
('profile/index.html', 'screenshots/profile-index.jpg'),
('profile/edit-profile.html', 'screenshots/edit-profile.jpg'),
('profile/change-pwd.html', 'screenshots/change-pwd.jpg'),
]
},
'professional': {
'base_url': 'http://localhost:8000/emergency-app/professional',
'pages': [
('workbench/index.html', 'screenshots/index.jpg'),
('workbench/emergency-chat-ongoing.html', 'screenshots/emergency-chat-ongoing.jpg'),
('workbench/emergency-chat-done.html', 'screenshots/emergency-chat-done.jpg'),
('workbench/work-order-detail-ongoing.html', 'screenshots/work-order-detail-ongoing.jpg'),
('workbench/work-order-detail.html', 'screenshots/work-order-detail.jpg'),
('knowledge/index.html', 'screenshots/knowledge-index.jpg'),
('knowledge/article-detail.html', 'screenshots/knowledge-article-detail.jpg'),
('profile/index.html', 'screenshots/profile-index.jpg'),
('profile/edit-profile.html', 'screenshots/edit-profile.jpg'),
('profile/change-pwd.html', 'screenshots/change-pwd.jpg'),
]
}
}
def take_screenshot(url, output_path):
"""使用Puppeteer截图"""
try:
# 使用npx puppeteer-cli截图
cmd = [
'npx', 'puppeteer', 'screenshot',
'--url', url,
'--path', output_path,
'--width', '375',
'--height', '812',
'--device-scale-factor', '2'
]
result = subprocess.run(cmd, capture_output=True, timeout=30)
if result.returncode == 0:
print(f"✓ {output_path}")
return True
else:
print(f"✗ {output_path}: {result.stderr.decode()}")
return False
except Exception as e:
print(f"✗ {output_path}: {e}")
return False
def main():
base_dir = Path('D:/AI/work/platform-prototype/emergency-app')
for role, config in PAGES.items():
print(f"\n[{role}] Starting screenshots...")
role_dir = base_dir / role / 'doc'
for page_path, screenshot_rel in config['pages']:
url = f"{config['base_url']}/{page_path}"
output_path = str(role_dir / screenshot_rel)
# 确保目录存在
Path(output_path).parent.mkdir(parents=True, exist_ok=True)
take_screenshot(url, output_path)
time.sleep(1) # 避免请求过快
if __name__ == '__main__':
main()