运行环境和截图来源
SOURCE
#!/usr/bin/env python3
"""Build an offline review gallery from untouched, locally captured app screenshots."""
from __future__ import annotations
import argparse
import html
import json
import pathlib
import hashlib
import struct
import subprocess
import zipfile
from collections import Counter
TITLES = {
"home": "机巢工作台", "statistics": "工作台 · 统计区域", "orders": "我的拍摄订单",
"payment-empty": "套餐收款 · 未选择套餐", "payment": "套餐收款", "receipts": "收款记录",
"preparation": "拍摄准备", "task-ready": "拍摄任务 · 到达待开拍", "task-shooting": "拍摄任务 · 拍摄中",
"task-completion-dialog": "拍摄任务 · 完成提示", "task-completed": "拍摄任务 · 拍摄已完成",
"task-paused": "拍摄任务 · 手动暂停", "task-returning": "拍摄任务 · 返航中",
"task-returned": "拍摄任务 · 已回巢", "task-pending-pause": "拍摄任务 · 暂停指令等待",
"task-starting": "拍摄任务 · 起飞准备", "task-failed": "拍摄任务 · 失败",
"task-going": "拍摄任务 · 前往点位",
"materials": "订单素材库", "material-preview": "素材预览", "delivery-method": "交付方式选择",
"delivery-cloud": "云端交付", "delivery-nearby": "面对面闪传", "confirmation": "订单交付确认",
"confirmation-code": "确认收货二维码", "confirmation-completed": "订单交付确认 · 已完成",
"project-picker": "套餐选择", "amount-edit": "设置金额", "live-fullscreen": "图传全屏",
}
ALIASES = {
"dock-workbench": "home", "dock-workbench-statistics": "statistics", "dock-orders": "orders",
"dock-payment-before-selection": "payment-empty", "dock-payment": "payment", "dock-receipts": "receipts",
"dock-preparation": "preparation", "dock-materials": "materials", "dock-material-preview": "material-preview",
"dock-delivery-methods": "delivery-method", "dock-delivery-cloud": "delivery-cloud",
"dock-delivery-nearby": "delivery-nearby", "dock-confirmation-manifest": "confirmation",
"dock-confirmation-code": "confirmation-code", "task-returning-complete": "task-completed",
"task-control-paused": "task-paused", "task-control-returning": "task-returning",
"task-control-returned": "task-returned", "task-control-pending-pause": "task-pending-pause",
"task-control-starting": "task-starting",
}
ORDER = ["home", "statistics", "orders", "payment-empty", "payment", "project-picker", "amount-edit", "receipts", "preparation",
"task-starting", "task-going", "task-ready", "task-shooting", "task-paused", "task-returning", "task-returned", "task-completed",
"task-completion-dialog", "task-failed", "task-pending-pause", "materials", "material-preview", "delivery-method",
"delivery-cloud", "delivery-nearby", "confirmation", "confirmation-code", "confirmation-completed", "live-fullscreen"]
def read_manifest(root: pathlib.Path, platform: str):
directory = root / platform
path = directory / "manifest.json"
metadata = json.loads(path.read_text()) if path.exists() else {}
if isinstance(metadata, list):
records = metadata
metadata = {}
else:
records = metadata.get("screenshots", metadata.get("screens", metadata.get("pages", [])))
files = {p.name: p for p in directory.glob("*.png")}
result = []
seen = set()
for record in records:
if isinstance(record, str):
record = {"filename": record}
filename = record.get("filename", record.get("file", record.get("path", "")))
filename = pathlib.Path(filename).name
if filename not in files:
continue
stem = pathlib.Path(filename).stem
key = record.get("pageKey", record.get("key", record.get("page", stem)))
key = ALIASES.get(key, ALIASES.get(stem, key))
item = {**record, "filename": filename, "key": key, "platform": platform,
"path": str(files[filename].relative_to(root)), "title": record.get("title", TITLES.get(key, stem))}
result.append(item)
seen.add(filename)
for filename, path in files.items():
if filename in seen:
continue
key = ALIASES.get(path.stem, path.stem)
result.append({"filename": filename, "key": key, "platform": platform,
"path": str(path.relative_to(root)), "title": TITLES.get(key, path.stem)})
used_keys = {}
for item in result:
path = root / item["path"]
raw = path.read_bytes()
width, height = struct.unpack(">II", raw[16:24])
item["dimensions"] = f"{width} × {height}"
item["sha256"] = hashlib.sha256(raw).hexdigest()
if item["key"] == "task-failed" and platform == "ios":
item["note"] = "执行失败,等待设备确认回巢;右侧为中断后已回巢,模拟状态不同。"
if item["key"] == "delivery-method":
item["note"] = "由工作台打开交付方式弹层。" if platform == "ios" else "由订单素材库打开交付方式弹层。"
count = used_keys.get(item["key"], 0) + 1
used_keys[item["key"]] = count
if count > 1:
item["original_key"] = item["key"]
item["key"] = f'{item["key"]}-extra-{count}'
return metadata, result
def pair_records(ios, android):
ios_map = {r["key"]: r for r in ios}
android_map = {r["key"]: r for r in android}
keys = list(dict.fromkeys(ORDER + list(ios_map) + list(android_map)))
return [{"key": k, "title": TITLES.get(k, (ios_map.get(k) or android_map.get(k))["title"]),
"ios": ios_map.get(k), "android": android_map.get(k)}
for k in keys if k in ios_map or k in android_map]
def build_html(root: pathlib.Path, pairs, platforms):
escaped = lambda value: html.escape(str(value), quote=True)
navigation = "".join(f'{i:02d} {escaped(p["title"])}' for i, p in enumerate(pairs, 1))
sections = []
for i, pair in enumerate(pairs, 1):
columns = []
for platform, label in [("ios", "iOS"), ("android", "Android")]:
screen = pair[platform]
if screen:
path = escaped(screen["path"])
title = escaped(pair["title"])
dimensions = screen.get("dimensions", "")
note = screen.get("note", screen.get("notes", ""))
if isinstance(note, list):
note = ";".join(note)
columns.append(f' {escaped(note)}'
f'
{escaped(note)}
' if note else '' columns.append( f'' ) unmatched = '' if pair['ios'] and pair['android'] else '单端补充' comparison_path = f'comparison/{i:02d}-{pair["key"]}.png' sections.append(f'2026-11-05 · 当前源码正式页面 · 隔离模拟数据
左列 iOS,中列 Android,右列为推荐基准与理由;窄屏时建议显示在截图下方。点击截图可查看完整原图,两端按等宽展示。
iOS 使用截图专用副本,仅加入依赖替身和启动入口,正式页面布局原样保留。Android 使用当前正式 Screen 与隔离测试替身。
任务、设备、游客、图传均为本地模拟来源;两端模拟图传配置及业务数据可能不同,画面状态差异不能代表真实设备行为。二维码为本地测试图形,不对应真实付款或收货。
推荐仅针对本次可见的布局、文案与操作层级。两端一致时保留各端;缺图或模拟状态不同的组注明待核对。系统导航、键盘与安全区遵循平台习惯。
SOURCE