Refine dashboard app UI

This commit is contained in:
Your Name committed 2026-06-18 12:51:03 +08:00
1 parent 22e2ed1508
commit b9b580f521
14 files changed
+1351 -453

No files matched your search

@@ -0,0 +1,16 @@
# 2026-06-18 gui_dashboard_app 新 UI 入口美化交接
- 范围:只改 `gui/dashboard_app` 新入口、`gui/gui_dashboard_app_entry.py` 入口关联和 `tools/gui` 导出工具。
- 旧入口:未改 `gui/gui_app.py`。
- 功能边界:以 20 页真实导出图为准,不新增/删除页面和功能。
- 页面数:`PAGES=20`。
- 视觉方向:浅色桌面 App、固定侧栏、顶部工具栏、底部运行栏、圆角按钮、轻量卡片、紧凑表格。
- 模块化:拆分为 `page_home/page_config/page_debug/page_data/page_registry/page_helpers/page_context`。
- 交互保留:刷新设备、扫描 WiFi、WiFi ADB、截图+OCR、保存配置、开始/停止/强制停止/返回键。
- 文本框保留:关键词、养号评论文案、爱心/收藏关键词切页不丢。
- 验证:`python -m py_compile` PASS。
- 验证:20 页 Tk 构建遍历 PASS。
- 验证:`git diff --check` PASS。
- 视觉核对包:`artifacts/gui_dashboard_ui_review_20260618_124233/index.html`。
- 视觉总览:`artifacts/gui_dashboard_ui_review_20260618_124233/contact-sheet.jpg`。
- 注意:`artifacts/` 为验收产物,未纳入提交。
+239 -45
View File
@@ -4,85 +4,162 @@ import tkinter as tk
from tkinter import ttk
from douyin.core.version import print_version_banner
from gui.components.config_io import save_ui_to_config
from gui.components.config_vars import build_config_vars
from gui.components.run_params_builder import get_params as build_run_params
from gui.gui_core import Runner, read_config, write_config
from gui.components.screenshot_action import do_screenshot
from gui.components.wifi_adb_dialog import open_wifi_adb_dialog
from gui.components.wifi_adb_one_click_scan import on_scan_one_click
from gui.components.wifi_adb_pick_dialog import open_scan_pick_dialog
from gui.components.wifi_adb_reconnect import try_reconnect_last_wifi
from gui.gui_core import Runner, find_adb_executable, list_adb_devices, read_config, write_config
from . import theme
from .data import load_dashboard_data
from .pages import PAGES
from .widgets import ScrollFrame, clear
from .page_context import PageContext
from .page_registry import PAGES
from .widgets import ScrollFrame, button, clear, nav_button, status_pill
class DashboardApp:
def __init__(self) -> None:
self.root = tk.Tk()
self.root.title("抖音福袋挂机 - 数据看板")
self.root.geometry("1480x940")
self.root.minsize(1180, 760)
try:
self.root.tk.call("tk", "scaling", 1.0)
except Exception:
pass
self.root.title("抖音自动化助手 - 数据看板")
self.root.geometry("1280x860")
self.root.minsize(1080, 720)
theme.setup_styles(self.root)
self.data = load_dashboard_data()
self.runner = Runner(self._on_runner_line)
self.config_vars = build_config_vars(self.data.cfg)
self.text_widgets: dict[str, tk.Text] = {}
self.text_cache = {
"want_text": self.data.cfg.get("contains_want", []) or [],
"not_want_text": self.data.cfg.get("contains_not_want", []) or [],
"yg_comment_texts": self.data.cfg.get("yanghao_comment_texts", []) or [],
"yg_like_keywords_text": self.data.cfg.get("yanghao_like_keywords", []) or [],
"yg_fav_keywords_text": self.data.cfg.get("yanghao_fav_keywords", []) or [],
}
self.current_page = "数据看板"
self.status_var = tk.StringVar(value="就绪")
self.device_var = tk.StringVar(value="自动选择设备")
self.y_var = tk.StringVar(value=str(self.data.cfg.get("y_pianyi", 0) if isinstance(self.data.cfg, dict) else 0))
self.adb_exe = find_adb_executable()
self.device_var = tk.StringVar(value="")
self.y_var = self.config_vars.get("y_var", tk.IntVar(value=0))
self.image_var = tk.StringVar(value="screenshot.png")
self.ocr_results: list = []
self._scan_busy = {"flag": False}
self.nav_buttons: dict[str, tk.Widget] = {}
self._build_shell()
self.status_var.trace_add("write", lambda *_: self._sync_status_pill())
self.refresh_devices(silent=True)
self.root.after(300, self._try_reconnect_last_wifi)
self.show_page(self.current_page)
def _build_shell(self) -> None:
root = self.root
shell = ttk.Frame(root, style="Dashboard.TFrame")
shell = ttk.Frame(self.root, style="Dashboard.TFrame")
shell.pack(fill="both", expand=True)
top = ttk.Frame(shell, style="Dashboard.TFrame")
top.pack(fill="x", padx=18, pady=(14, 8))
ttk.Label(top, text="抖音福袋挂机", style="Title.TLabel").pack(side="left", padx=(0, 16))
ttk.Label(top, text="设备:", background=theme.BG, foreground=theme.MUTED).pack(side="left")
ttk.Combobox(top, textvariable=self.device_var, values=["自动选择设备"], width=28).pack(side="left", padx=(4, 8))
for text, command in [
("刷新设备", self.refresh_data),
("扫描WiFi", self._noop),
("WiFi ADB", lambda: self.show_page("WiFi ADB")),
]:
ttk.Button(top, text=text, style="Soft.TButton", command=command).pack(side="left", padx=4)
ttk.Label(top, text="Y偏移:", background=theme.BG, foreground=theme.MUTED).pack(side="left", padx=(10, 3))
ttk.Spinbox(top, from_=-200, to=200, textvariable=self.y_var, width=6).pack(side="left")
ttk.Button(top, text="保存配置", style="Soft.TButton", command=self._noop).pack(side="right", padx=4)
ttk.Button(top, text="截图+OCR", style="Primary.TButton", command=self.refresh_data).pack(side="right", padx=4)
top = tk.Frame(shell, bg=theme.SURFACE, highlightbackground=theme.BORDER, highlightthickness=1)
top.pack(fill="x", padx=16, pady=(12, 7))
brand = tk.Frame(top, bg=theme.SURFACE)
brand.pack(fill="x", padx=14, pady=(8, 3))
mark = tk.Frame(brand, bg=theme.TEAL, width=28, height=28)
mark.pack(side="left", padx=(0, 9))
mark.pack_propagate(False)
tk.Label(mark, text="抖", bg=theme.TEAL, fg="#ffffff", font=("Microsoft YaHei UI", 11, "bold")).pack(expand=True)
title_box = tk.Frame(brand, bg=theme.SURFACE)
title_box.pack(side="left")
tk.Label(title_box, text="抖音自动化助手", bg=theme.SURFACE, fg=theme.TEXT, font=("Microsoft YaHei UI", 14, "bold")).pack(anchor="w")
tk.Label(title_box, text="轻量数据看板入口", bg=theme.SURFACE, fg=theme.SUBTLE, font=theme.FONT_SMALL).pack(anchor="w")
tool_row = tk.Frame(top, bg=theme.SURFACE)
tool_row.pack(fill="x", padx=14, pady=(0, 8))
ttk.Label(tool_row, text="设备:", background=theme.SURFACE, foreground=theme.MUTED).pack(side="left")
self.device_combo = ttk.Combobox(tool_row, textvariable=self.device_var, values=[], width=28)
self.device_combo.pack(side="left", padx=(4, 8))
button(tool_row, "刷新设备", self.refresh_devices, width=104).pack(side="left", padx=3)
self.scan_button = button(tool_row, "扫描 WiFi", self.scan_wifi, width=106)
self.scan_button.pack(side="left", padx=4)
button(tool_row, "WiFi ADB", self.open_wifi_adb, width=98).pack(side="left", padx=3)
ttk.Label(tool_row, text="Y偏移:", background=theme.SURFACE, foreground=theme.MUTED).pack(side="left", padx=(8, 3))
ttk.Spinbox(tool_row, from_=-200, to=200, textvariable=self.y_var, width=6).pack(side="left")
button(tool_row, "保存配置", self.save_config, width=104).pack(side="right", padx=3)
button(tool_row, "截图+OCR", self.screenshot_ocr, kind="primary", width=110).pack(side="right", padx=3)
main = ttk.Frame(shell, style="Dashboard.TFrame")
main.pack(fill="both", expand=True, padx=18, pady=8)
main.pack(fill="both", expand=True, padx=16, pady=(4, 7))
main.grid_columnconfigure(1, weight=1)
main.grid_rowconfigure(0, weight=1)
sidebar = ttk.Frame(main, style="Surface.TFrame")
sidebar = tk.Frame(main, bg=theme.SURFACE, highlightbackground=theme.BORDER, highlightthickness=1)
sidebar.grid(row=0, column=0, sticky="nsw", padx=(0, 14))
sidebar.configure(width=188)
sidebar.grid_propagate(False)
sidebar.pack_propagate(False)
for group_title, names in [
("总览", ["数据看板"]),
("配置", ["运行设置", "筛选设置", "高价值预约", "养号设置", "调试参数", "授权", "日志配置", "关键词"]),
("数据", ["运行日志", "截图预览", "统计信息", "预约队列", "高价值房间", "行为日志", "实时状态", "OCR结果", "中奖记录", "映射表"]),
("连接", ["WiFi ADB"]),
]:
ttk.Label(sidebar, text=group_title, background=theme.SURFACE, foreground=theme.MUTED, font=theme.FONT_SMALL).pack(anchor="w", padx=14, pady=(14, 5))
ttk.Label(sidebar, text=group_title, background=theme.SURFACE, foreground=theme.MUTED, font=theme.FONT_SMALL).pack(anchor="w", padx=12, pady=(10, 3))
for name in names:
ttk.Button(sidebar, text=name, style="Sidebar.TButton", command=lambda n=name: self.show_page(n)).pack(fill="x", padx=10, pady=2)
btn = nav_button(sidebar, name, lambda n=name: self.show_page(n), active=name == self.current_page)
btn.pack(fill="x", padx=8, pady=0)
self.nav_buttons[name] = btn
self.content_scroll = ScrollFrame(main)
self.content_scroll.grid(row=0, column=1, sticky="nsew")
self.content = self.content_scroll.inner
bottom = ttk.Frame(shell, style="Dashboard.TFrame")
bottom.pack(fill="x", padx=18, pady=(4, 14))
ttk.Button(bottom, text="开始运行", style="Primary.TButton", command=self.start_run).pack(side="left", padx=(0, 8))
ttk.Button(bottom, text="停止", style="Soft.TButton", command=self.stop_run).pack(side="left", padx=4)
ttk.Button(bottom, text="强制停止", style="Danger.TButton", command=self.force_stop_run).pack(side="left", padx=4)
ttk.Button(bottom, text="发送返回键", style="Soft.TButton", command=self.send_back_key).pack(side="left", padx=8)
ttk.Label(bottom, textvariable=self.status_var, background=theme.BG, foreground=theme.GREEN).pack(side="right")
bottom = tk.Frame(shell, bg=theme.SURFACE, highlightbackground=theme.BORDER, highlightthickness=1)
bottom.pack(fill="x", padx=16, pady=(3, 12))
inner_bottom = tk.Frame(bottom, bg=theme.SURFACE)
inner_bottom.pack(fill="x", padx=10, pady=7)
button(inner_bottom, "开始运行", self.start_run, kind="primary", width=86).pack(side="left", padx=(0, 7))
button(inner_bottom, "停止", self.stop_run, width=70).pack(side="left", padx=3)
button(inner_bottom, "强制停止", self.force_stop_run, kind="danger", width=86).pack(side="left", padx=3)
button(inner_bottom, "发送返回键", self.send_back_key, width=96).pack(side="left", padx=7)
self.status_pill = status_pill(inner_bottom, "就绪")
self.status_pill.pack(side="right")
def _noop(self) -> None:
self.status_var.set("新版看板入口:当前操作保留为独立预览")
def _sync_nav(self) -> None:
for name, btn in self.nav_buttons.items():
active = name == self.current_page
if hasattr(btn, "set_active"):
btn.set_active(active)
def _sync_status_pill(self) -> None:
if not hasattr(self, "status_pill"):
return
text = self.status_var.get() or "就绪"
color = theme.GREEN
bg = theme.GREEN_SOFT
if "失败" in text or "异常" in text:
color, bg = theme.RED, theme.RED_SOFT
elif "运行" in text or "扫描" in text:
color, bg = theme.TEAL, theme.TEAL_SOFT
elif "未" in text:
color, bg = theme.AMBER, theme.AMBER_SOFT
self.status_pill.configure(text=text, fg=color, bg=bg)
def _actions(self) -> dict:
return {
"refresh": self.refresh_data,
"refresh_devices": self.refresh_devices,
"save_config": self.save_config,
"screenshot_ocr": self.screenshot_ocr,
"scan_wifi": self.scan_wifi,
"wifi_adb": self.open_wifi_adb,
}
def _selected_device(self) -> str:
dev = self.device_var.get().strip()
return "" if dev in {"", "自动选择设备"} else dev
def _on_runner_line(self, line: str) -> None:
try:
@@ -95,18 +172,132 @@ class DashboardApp:
self.config_vars = build_config_vars(read_config())
except Exception:
pass
self.config_vars["device_var"] = self.device_var
self.config_vars["device_var"] = tk.StringVar(value=self._selected_device())
self.config_vars["y_var"].set(int(self.y_var.get() or 0))
return build_run_params(self.config_vars)
def _ensure_text_widgets(self) -> None:
for key, lines in self.text_cache.items():
widget = self.text_widgets.get(key)
if widget is not None:
try:
if widget.winfo_exists():
continue
except Exception:
pass
text = tk.Text(self.root)
text.insert("1.0", "\n".join(str(x) for x in lines))
self.text_widgets[key] = text
def _capture_text_widgets(self) -> None:
for key, widget in list(self.text_widgets.items()):
try:
if not widget.winfo_exists():
continue
lines = [x.strip() for x in widget.get("1.0", "end").splitlines() if x.strip()]
self.text_cache[key] = lines
except Exception:
continue
def _apply_text_cache_to_data(self) -> None:
self.data.cfg["contains_want"] = self.text_cache.get("want_text", [])
self.data.cfg["contains_not_want"] = self.text_cache.get("not_want_text", [])
self.data.cfg["yanghao_comment_texts"] = self.text_cache.get("yg_comment_texts", [])
self.data.cfg["yanghao_like_keywords"] = self.text_cache.get("yg_like_keywords_text", [])
self.data.cfg["yanghao_fav_keywords"] = self.text_cache.get("yg_fav_keywords_text", [])
def save_config(self) -> None:
try:
self._capture_text_widgets()
self._ensure_text_widgets()
self.config_vars["y_var"].set(int(self.y_var.get() or 0))
save_ui_to_config(
vars_=self.config_vars,
texts_=self.text_widgets,
cfg=self.data.cfg,
read_config=read_config,
write_config=write_config,
on_line=self._on_runner_line,
)
self.data = load_dashboard_data()
self.status_var.set("配置已保存")
except Exception as exc:
self.status_var.set(f"保存失败:{exc}")
def refresh_devices(self, silent: bool = False) -> None:
try:
self.adb_exe = find_adb_executable()
devices = list_adb_devices(self.adb_exe)
values = devices or ["自动选择设备"]
self.device_combo["values"] = values
if self.device_var.get() not in values:
self.device_var.set(devices[0] if devices else "自动选择设备")
if not silent:
self.status_var.set(f"已刷新设备:{len(devices)} 台" if devices else "未发现设备")
except Exception as exc:
if not silent:
self.status_var.set(f"刷新设备失败:{exc}")
def open_wifi_adb(self) -> None:
self.show_page("WiFi ADB")
open_wifi_adb_dialog(
self.root,
adb_exe=self.adb_exe,
on_line=self._on_runner_line,
refresh_devices=self.refresh_devices,
)
def _open_scan_pick_dialog(self, devs) -> None:
open_scan_pick_dialog(
self.root,
devs,
device_var=self.device_var,
on_line=self._on_runner_line,
refresh_devices=self.refresh_devices,
)
def scan_wifi(self) -> None:
on_scan_one_click(
adb_exe=self.adb_exe,
scan_btn=self.scan_button,
scan_busy=self._scan_busy,
root=self.root,
on_line=self._on_runner_line,
device_var=self.device_var,
refresh_devices=self.refresh_devices,
open_pick_dialog=self._open_scan_pick_dialog,
)
def _try_reconnect_last_wifi(self) -> None:
try_reconnect_last_wifi(
self.root,
adb_exe=self.adb_exe,
device_var=self.device_var,
on_line=self._on_runner_line,
refresh_devices=self.refresh_devices,
)
def screenshot_ocr(self) -> None:
do_screenshot(
device_id=self._selected_device(),
y_offset=int(self.y_var.get() or 0),
image_var=self.image_var,
on_line=self._on_runner_line,
root=self.root,
on_ocr_results=self._set_ocr_results,
on_refresh_preview=self.refresh_data,
)
def _set_ocr_results(self, results: list) -> None:
self.ocr_results = results
self.status_var.set(f"OCR结果已更新:{len(results)} 项")
def start_run(self) -> None:
if self.runner.is_running():
self.status_var.set("已在运行中")
return
try:
cfg = read_config()
cfg["y_pianyi"] = int(self.y_var.get() or 0)
write_config(cfg)
self.save_config()
self.runner.start(self._params())
self.status_var.set("运行中")
self.refresh_data()
@@ -122,8 +313,7 @@ class DashboardApp:
self.status_var.set("已停止(强制)")
def send_back_key(self) -> None:
dev = self.device_var.get().strip()
ok = self.runner.send_back_key("" if dev == "自动选择设备" else dev)
ok = self.runner.send_back_key(self._selected_device())
self.status_var.set("返回键已发送" if ok else "发送返回键失败")
def refresh_data(self) -> None:
@@ -133,9 +323,13 @@ class DashboardApp:
def show_page(self, name: str) -> None:
self.current_page = name
self._sync_nav()
self._capture_text_widgets()
self._apply_text_cache_to_data()
self._ensure_text_widgets()
clear(self.content)
builder = PAGES.get(name, PAGES["数据看板"])
builder(self.content, self.data)
builder(self.content, self.data, PageContext(self.config_vars, self.text_widgets, self._actions()))
try:
self.content_scroll.canvas.yview_moveto(0)
except Exception:
+173
View File
@@ -0,0 +1,173 @@
from __future__ import annotations
import tkinter as tk
from . import theme
from .data import DashboardData, cfg_get
from .page_context import PageContext
from .page_helpers import pack_fields, pack_switches, text_box
from .widgets import button, card, section
def build_run_settings(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "运行设置", "保持旧入口运行参数")
box = card(parent, "基本运行参数")
box.pack(fill="x")
pack_switches(box, ctx, [
("允许切换直播间", "needswitch_var", bool(cfg_get(data.cfg, "needswitch"))),
("无限循环模式", "infinite_loop_var", bool(cfg_get(data.cfg, "infinite_loop_enabled"))),
("切换N次后回到第一个", "reset_after_swipes_enabled_var", False),
("启用返回键回退", "enable_back_on_misses_var", True),
("启用下滑回退直播间", "swipe_down_back_enabled_var", False),
])
pack_fields(box, ctx, [
("运行时长(分钟)", "wait_minutes_var", cfg_get(data.cfg, "wait_minutes")),
("倒计时大于(秒)时不参与", "skip_gt_seconds_var", cfg_get(data.cfg, "skip_if_countdown_gt_seconds")),
("次数", "reset_after_swipes_var", cfg_get(data.cfg, "reset_after_swipes")),
("滑动重置回退方式", "reset_after_swipes_action_var", cfg_get(data.cfg, "reset_after_swipes_action")),
("进入直播间坐标模式", "reenter_live_entry_mode_var", cfg_get(data.cfg, "reenter_live_entry_mode")),
("下滑回退次数", "swipe_down_back_count_var", cfg_get(data.cfg, "swipe_down_back_count")),
("连续无福袋退出阈值", "fudai_exit_after_misses_var", cfg_get(data.cfg, "fudai_exit_after_misses")),
])
def build_filter_settings(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "筛选设置", "价值 / 人数 / 倒计时 / 粉丝团")
box = card(parent, "福袋筛选条件")
box.pack(fill="x")
pack_switches(box, ctx, [("自动加入粉丝团(谨慎:可能消耗钻石)", "auto_join_var", False)], columns=1)
pack_fields(box, ctx, [
("最低价值(元)", "min_value_var", cfg_get(data.cfg, "min_prize_value_yuan")),
("参与人数最小", "min_participants_var", cfg_get(data.cfg, "min_participants")),
("参与人数最大", "max_participants_var", cfg_get(data.cfg, "max_participants")),
("倒计时小于(秒)时不参与", "skip_lt_seconds_var", cfg_get(data.cfg, "skip_if_countdown_lt_seconds")),
("粉丝团失败策略", "fansclub_action_var", cfg_get(data.cfg, "fansclub_fail_action")),
("粉丝团点击延迟(s)", "fansclub_click_delay_var", cfg_get(data.cfg, "fansclub_click_delay")),
("自动加入等待(s)", "fansclub_auto_wait_var", cfg_get(data.cfg, "fansclub_auto_join_wait_seconds")),
("手动加入等待(s)", "fansclub_manual_wait_var", cfg_get(data.cfg, "fansclub_manual_wait_seconds")),
])
def build_reservation_settings(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "高价值预约", "预约参与 / 房间回访 / 回退校验")
box = card(parent, "高价值福袋预约参与")
box.pack(fill="x")
pack_switches(box, ctx, [
("启用预约(价值≥阈值)", "high_value_fudai_enabled_var", False),
("启用高价值房间回访", "high_value_room_revisit_enabled_var", True),
("仅当前运行", "high_value_room_revisit_only_current_run_var", False),
("预约回退校验", "reservation_back_verify_enabled_var", True),
])
pack_fields(box, ctx, [
("价值阈值(元)", "high_value_fudai_threshold_yuan_var", cfg_get(data.cfg, "high_value_fudai_threshold_yuan")),
("提前参与(秒)", "high_value_fudai_join_ahead_seconds_var", cfg_get(data.cfg, "high_value_fudai_join_ahead_seconds")),
("最多回退直播间次数", "high_value_fudai_max_swipe_back_var", cfg_get(data.cfg, "high_value_fudai_max_swipe_back")),
("最多记录数量", "high_value_fudai_max_reservations_var", cfg_get(data.cfg, "high_value_fudai_max_reservations")),
("完成后策略", "high_value_fudai_after_action_var", cfg_get(data.cfg, "high_value_fudai_after_action")),
("重访最小间隔(秒)", "high_value_room_revisit_min_interval_seconds_var", cfg_get(data.cfg, "high_value_room_revisit_min_interval_seconds")),
("每次运行最大次数", "high_value_room_revisit_max_per_run_var", cfg_get(data.cfg, "high_value_room_revisit_max_per_run")),
("最低奖品价值(元)", "high_value_room_revisit_min_prize_value_var", cfg_get(data.cfg, "high_value_room_revisit_min_prize_value")),
("最大年龄(天)", "high_value_room_revisit_max_age_days_var", cfg_get(data.cfg, "high_value_room_revisit_max_age_days")),
("开奖前轮询时间(秒)", "high_value_fudai_poll_before_seconds_var", cfg_get(data.cfg, "high_value_fudai_poll_before_seconds")),
("回退滑延迟(秒)", "reservation_back_swipe_delay_var", cfg_get(data.cfg, "reservation_back_swipe_delay")),
("校验等待时间(秒)", "reservation_back_verify_wait_seconds_var", cfg_get(data.cfg, "reservation_back_verify_wait_seconds")),
])
def build_yanghao_settings(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "养号设置", "推荐页养号 / 互动动作 / 定时禁抢")
box = card(parent, "推荐页养号(爱心/收藏/评论)")
box.pack(fill="x", pady=(0, 12))
pack_switches(box, ctx, [
("养号总开关(关闭则跳过推荐页养号)", "yg_enabled_var", True),
("启用养号动作(爱心/收藏/评论)", "yg_actions_enabled_var", True),
("只养号(仅执行推荐页养号,跳过抽奖/参与)", "yg_only_var", False),
("逐步截图(调试用,生成 pic/*/latest.png)", "yg_step_screenshot_var", False),
("启用定时禁抢", "fudai_quiet_hours_enabled_var", True),
])
pack_fields(box, ctx, [
("养号时长(秒)", "yg_recommend_duration_var", cfg_get(data.cfg, "yanghao_recommend_duration_seconds")),
("养号间隔(秒)", "yg_recommend_interval_var", cfg_get(data.cfg, "yanghao_recommend_interval_seconds")),
("爱心概率", "yg_like_prob_var", cfg_get(data.cfg, "yanghao_like_prob")),
("收藏概率", "yg_fav_prob_var", cfg_get(data.cfg, "yanghao_fav_prob")),
("评论概率", "yg_comment_prob_var", cfg_get(data.cfg, "yanghao_comment_prob")),
("检测动作后停留最小(秒)", "yg_dwell_on_action_min_var", cfg_get(data.cfg, "yanghao_dwell_on_action_min_seconds")),
("检测动作后停留最大(秒)", "yg_dwell_on_action_max_var", cfg_get(data.cfg, "yanghao_dwell_on_action_max_seconds")),
("图标ROI大小(px)", "yg_icon_roi_size_var", cfg_get(data.cfg, "yanghao_icon_roi_size")),
("匹配阈值", "yg_icon_match_threshold_var", cfg_get(data.cfg, "yanghao_icon_match_threshold")),
("开始小时", "fudai_quiet_start_hour_var", cfg_get(data.cfg, "fudai_quiet_start_hour")),
("结束小时", "fudai_quiet_end_hour_var", cfg_get(data.cfg, "fudai_quiet_end_hour")),
])
texts = tk.Frame(parent, bg=theme.BG)
texts.pack(fill="both", expand=True)
texts.grid_columnconfigure(0, weight=1)
texts.grid_columnconfigure(1, weight=1)
left = tk.Frame(texts, bg=theme.BG)
right = tk.Frame(texts, bg=theme.BG)
left.grid(row=0, column=0, sticky="nsew", padx=(0, 8))
right.grid(row=0, column=1, sticky="nsew", padx=(8, 0))
text_box(left, ctx, "yg_comment_texts", "评论文案库(每行一条)", data.cfg.get("yanghao_comment_texts", []) or [], height=7)
text_box(right, ctx, "yg_like_keywords_text", "爱心关键词(每行一条)", data.cfg.get("yanghao_like_keywords", []) or [], height=3)
text_box(right, ctx, "yg_fav_keywords_text", "收藏关键词(每行一条)", data.cfg.get("yanghao_fav_keywords", []) or [], height=3)
def build_logging(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "日志配置", "日志格式、保留策略、实时状态刷新")
box = card(parent, "日志与界面")
box.pack(fill="x")
pack_switches(box, ctx, [
("启用日志美化", "logging_beautify_var", True),
("启用颜色显示", "logging_color_var", True),
("显示时间戳", "logging_show_timestamps_var", True),
("启用日志监控(超限告警/触发清理)", "logging_enable_monitor_var", True),
("按日期拆分日志", "logging_use_dated_logs_var", True),
("写入统一日志", "log_unified_enabled_var", True),
("压缩旧日志", "logging_compress_logs_var", True),
("启用性能追踪", "logging_performance_enabled_var", True),
("追踪函数调用", "logging_track_functions_var", True),
("流式后台截图(加速但可能导致并发读取)", "streaming_enabled_var", True),
("详细阶段诊断日志", "stage_diag_verbose_var", False),
])
pack_fields(box, ctx, [
("日志格式模式", "logging_format_mode_var", cfg_get(data.cfg, "logging", "log_format_mode")),
("统一日志路径", "log_unified_path_var", cfg_get(data.cfg, "log_unified_path")),
("保留天数", "logging_keep_days_var", cfg_get(data.cfg, "logging", "keep_days")),
("总量上限(GB)", "logging_max_total_size_gb_var", cfg_get(data.cfg, "logging", "max_total_size_gb")),
("压缩阈值(天)", "logging_compress_after_days_var", cfg_get(data.cfg, "logging", "compress_after_days")),
("日志总大小警告阈值(MB)", "logging_monitor_warning_mb_var", cfg_get(data.cfg, "logging", "monitor_warning_mb")),
("严重阈值(MB)", "logging_monitor_critical_mb_var", cfg_get(data.cfg, "logging", "monitor_critical_mb")),
("日志调试详细度", "logging_debug_level_var", cfg_get(data.cfg, "logging", "debug_detail_level")),
("错误详细度", "logging_error_level_var", cfg_get(data.cfg, "logging", "error_detail_level")),
("行为日志格式", "logging_action_format_var", cfg_get(data.cfg, "logging", "action_log_format")),
("界面主题", "gui_theme_var", cfg_get(data.cfg, "gui", "theme")),
("实时状态刷新(ms)", "gui_realtime_refresh_interval_ms_var", cfg_get(data.cfg, "gui", "realtime_status", "refresh_interval_ms")),
("实时状态条数", "gui_realtime_tail_items_var", cfg_get(data.cfg, "gui", "realtime_status", "tail_items")),
])
row = tk.Frame(box, bg=theme.SURFACE)
row.pack(fill="x", padx=20, pady=(0, 16))
button(row, "保存日志配置", ctx.action("save_config"), kind="primary").pack(side="left")
def build_keywords(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "关键词", "白名单与黑名单")
body = tk.Frame(parent, bg=theme.BG)
body.pack(fill="both", expand=True)
body.grid_columnconfigure(0, weight=1)
body.grid_columnconfigure(1, weight=1)
left = tk.Frame(body, bg=theme.BG)
right = tk.Frame(body, bg=theme.BG)
left.grid(row=0, column=0, sticky="nsew", padx=(0, 8))
right.grid(row=0, column=1, sticky="nsew", padx=(8, 0))
text_box(left, ctx, "want_text", "想要 contains_want(白名单,空=不限制)", data.cfg.get("contains_want", []) or [], height=18)
text_box(right, ctx, "not_want_text", "不想要 contains_not_want(黑名单)", data.cfg.get("contains_not_want", []) or [], height=18)
def build_license(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "授权", "卡密授权、本机机器码与授权文件")
box = card(parent, "卡密授权")
box.pack(fill="x")
pack_fields(box, ctx, [("授权状态", "", "本地检测"), ("本机机器码", "", ""), ("授权文件", "", "license.dat"), ("输入卡密", "", "")], columns=2)
row = tk.Frame(box, bg=theme.SURFACE)
row.pack(fill="x", padx=20, pady=(0, 16))
button(row, "安装卡密", None, kind="primary").pack(side="left", padx=(0, 8))
button(row, "刷新状态", None).pack(side="left")
+24
View File
@@ -0,0 +1,24 @@
from __future__ import annotations
import tkinter as tk
from typing import Callable
Action = Callable[[], None]
class PageContext:
def __init__(
self,
vars_: dict[str, tk.Variable],
texts: dict[str, tk.Text],
actions: dict[str, Action],
) -> None:
self.vars = vars_
self.texts = texts
self.actions = actions
def var(self, name: str) -> tk.Variable | None:
return self.vars.get(name)
def action(self, name: str) -> Action | None:
return self.actions.get(name)
+108
View File
@@ -0,0 +1,108 @@
from __future__ import annotations
import tkinter as tk
from . import theme
from .data import DashboardData, fmt_ts
from .page_context import PageContext
from .page_helpers import reservation_rows
from .widgets import flow_grid, preview_panel, section, stat_tile, table_panel, text_panel, toolbar
def build_run_log(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "运行日志", "筛选 / 搜索 / 刷新")
toolbar(parent, [("刷新", ctx.action("refresh"), "soft"), "上一个", "下一个", "清除"])
text_panel(parent, "最近运行日志", data.run_log, height=24).pack(fill="both", expand=True)
def build_preview(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "截图预览", "选择图片 / 打开pic目录 / 刷新预览")
toolbar(parent, [("刷新预览", ctx.action("refresh"), "soft"), ("截图+OCR", ctx.action("screenshot_ocr"), "primary"), "打开pic目录"])
preview_panel(parent, data.screenshot_path, "当前截图").pack(fill="both", expand=True)
def build_reservation_queue(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "预约队列", "预约队列总览与等待状态")
toolbar(parent, [("刷新", ctx.action("refresh"), "soft")])
rows = reservation_rows(data)
for row in rows:
row["time"] = fmt_ts(row["time"])
table_panel(parent, "预约队列", (
("idx", "#", 40), ("title", "直播间", 190), ("content", "内容", 250),
("value", "价值", 80), ("status", "状态", 90), ("time", "时间", 170),
), rows, height=18).pack(fill="both", expand=True)
def build_high_value(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "高价值房间", "持久化高价值记录")
toolbar(parent, [("刷新", ctx.action("refresh"), "soft")])
rows = []
for idx, item in enumerate(data.high_value_rooms[:50], 1):
rows.append({
"idx": idx,
"title": item.get("room_title") or item.get("title") or "-",
"content": item.get("content") or item.get("prize_content") or "-",
"value": item.get("prize_value_yuan") or item.get("value") or "-",
"status": item.get("status") or "已记录",
})
table_panel(parent, "高价值房间", (
("idx", "#", 40), ("title", "直播间", 220), ("content", "内容", 280),
("value", "价值", 90), ("status", "状态", 100),
), rows, height=20).pack(fill="both", expand=True)
def build_actions_log(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "行为日志", "关键字筛选 / 搜索 / 刷新")
toolbar(parent, [("刷新", ctx.action("refresh"), "soft"), "上一个", "下一个", "清除"])
text_panel(parent, "最近行为日志", data.action_log, height=24).pack(fill="both", expand=True)
def build_realtime(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "实时状态", "显示动作流 / 显示截图 / 自动滚动 / 查看大图")
toolbar(parent, ["显示动作流", "显示截图", "自动滚动", "查看大图"])
body = tk.Frame(parent, bg=theme.BG)
body.pack(fill="both", expand=True)
text_panel(body, "动作流", data.action_log[-120:], height=16).pack(fill="both", expand=True, pady=(0, 12))
preview_panel(body, data.screenshot_path, "实时截图").pack(fill="both", expand=True)
def build_ocr(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "OCR结果", "点击 截图+OCR 后更新")
toolbar(parent, [("截图+OCR", ctx.action("screenshot_ocr"), "primary"), ("刷新", ctx.action("refresh"), "soft")])
lines = []
for p in data.ocr_files[:8]:
lines.append(f"{p.name} {fmt_ts(p.stat().st_mtime)}")
text_panel(parent, "OCR结果", lines or ['暂无OCR结果,请先点击"截图+OCR"按钮'], height=24).pack(fill="both", expand=True)
def build_wins(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "中奖记录", "中奖截图列表与预览")
toolbar(parent, [("刷新列表", ctx.action("refresh"), "soft"), "打开目录", "保存误识别", "加载误识别"])
body = tk.Frame(parent, bg=theme.BG)
body.pack(fill="both", expand=True)
body.grid_columnconfigure(0, weight=4)
body.grid_columnconfigure(1, weight=5)
rows = [{"idx": i + 1, "file": p.name, "time": fmt_ts(p.stat().st_mtime)} for i, p in enumerate(data.win_images[:40])]
table_panel(body, "中奖截图列表", (("idx", "#", 40), ("file", "文件", 260), ("time", "时间", 160)), rows, height=18).grid(row=0, column=0, sticky="nsew", padx=(0, 8))
preview_panel(body, data.win_images[0] if data.win_images else None, "截图预览").grid(row=0, column=1, sticky="nsew", padx=(8, 0))
def build_mapping(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "映射表", "显示原始标题 / 刷新映射表 / 搜索 / 复制条目")
toolbar(parent, [("自动刷新(5s)", None, "soft"), ("刷新映射表", ctx.action("refresh"), "soft"), "显示原始标题", "清除", "复制条目"])
table_panel(parent, "运行时映射表", (
("pos", "位置", 80), ("title", "标题", 360), ("status", "状态", 100), ("updated", "更新时间", 180),
), data.mapping_rows, height=22).pack(fill="both", expand=True)
def build_wifi_adb(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "WiFi ADB", "扫描 WiFi / USB 授权提示 / 连接状态")
toolbar(parent, [("扫描WiFi", ctx.action("scan_wifi"), "primary"), ("WiFi ADB", ctx.action("wifi_adb"), "soft"), ("刷新设备", ctx.action("refresh_devices"), "soft")])
metrics = flow_grid(parent, 4)
for idx, item in enumerate([
("USB设备", "待检测", "首次启用", theme.TEAL, theme.TEAL_SOFT),
("扫描状态", "未扫描", "局域网", theme.BLUE, theme.BLUE_SOFT),
("默认端口", "5555", "ADB TCP", theme.AMBER, theme.AMBER_SOFT),
("当前设备", "设备选择器", "顶部下拉", theme.GREEN, theme.GREEN_SOFT),
]):
stat_tile(metrics, *item[:3], color=item[3], soft=item[4]).grid(row=0, column=idx, sticky="ew", padx=5)
+105
View File
@@ -0,0 +1,105 @@
from __future__ import annotations
import tkinter as tk
from .data import DashboardData, cfg_get
from .page_context import PageContext
from .page_helpers import pack_fields, pack_switches
from .widgets import card, section
def build_debug_settings(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "调试参数", "识别阈值 / OCR 开关 / 像素检测 / 坐标")
_debug_images(parent, data, ctx)
_fudai_find(parent, data, ctx)
_ocr_and_pixel(parent, data, ctx)
_diagnostics(parent, data, ctx)
def _debug_images(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
box = card(parent, "调试图像")
box.pack(fill="x", pady=(0, 12))
pack_switches(box, ctx, [
("全局调试图像(OCR / 像素 / 模板等)", "debug_captures_enabled_var", False),
("启用自动清理调试图像", "debug_captures_auto_cleanup_var", True),
("异步保存调试图像(默认启用)", "debug_captures_async_save_var", True),
("保存完成后记录日志(显示路径)", "debug_captures_log_on_complete_var", False),
], columns=2)
pack_fields(box, ctx, [
("保留天数", "debug_captures_keep_days_var", cfg_get(data.cfg, "debug_captures", "keep_days")),
("最大文件数量", "debug_captures_max_files_var", cfg_get(data.cfg, "debug_captures", "max_files")),
])
def _fudai_find(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
box = card(parent, "找福袋参数")
box.pack(fill="x", pady=(0, 12))
pack_switches(box, ctx, [
("禁用福袋内容OCR识别", "fudai_disable_content_recognition_var", False),
("禁用福袋任务列表OCR识别", "fudai_disable_task_recognition_var", False),
("保存福袋详情综合标注图", "fudai_detail_save_debug_images_var", False),
("启用坐标调整(默认关闭,避免滚轮误触)", "region_coords_edit_enabled_var", False),
], columns=2)
pack_fields(box, ctx, [
("找福袋最大尝试次数", "fudai_find_max_attempts_var", cfg_get(data.cfg, "fudai_find_max_attempts")),
("找福袋重试间隔(秒)", "fudai_icon_retry_delay_seconds_var", cfg_get(data.cfg, "fudai_icon_retry_delay_seconds")),
("最大等待时间(秒)", "fudai_icon_max_wait_seconds_var", cfg_get(data.cfg, "fudai_icon_max_wait_seconds")),
("点击福袋后等待时间(秒)", "fudai_click_wait_seconds_var", cfg_get(data.cfg, "fudai_click_wait_seconds")),
("福袋详情页UI版本", "fudai_detail_ui_mode_var", cfg_get(data.cfg, "fudai_detail_ui_mode")),
("切换直播间后等待时间(秒)", "switch_room_wait_after_stage_diag_seconds_var", cfg_get(data.cfg, "switch_room_wait_after_stage_diag_seconds")),
("直播间检测阈值", "live_room_match_threshold_var", cfg_get(data.cfg, "live_room_match_threshold")),
])
def _ocr_and_pixel(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
box = card(parent, "OCR 与像素检测开关")
box.pack(fill="x", pady=(0, 12))
pack_switches(box, ctx, [
("内容OCR", "fudai_detail_ocr_content_enabled_var", True),
("价值OCR", "fudai_detail_ocr_value_enabled_var", True),
("倒计时OCR", "fudai_detail_ocr_countdown_enabled_var", True),
("任务OCR", "fudai_detail_ocr_task_enabled_var", True),
("任务数量OCR", "fudai_detail_ocr_task_count_enabled_var", True),
("按钮文案OCR", "fudai_detail_ocr_button_enabled_var", True),
("人数OCR(默认关)", "fudai_detail_ocr_participants_enabled_var", False),
("直播间标题OCR(默认关)", "fudai_detail_ocr_live_title_enabled_var", False),
("启用OCR模式1(二值化)", "enable_ocr_mode1_var", False),
("启用福袋模板匹配", "fudai_template_match_enabled_var", False),
("福袋icon", "pixel_detect_fudai_icon_enabled_var", True),
("优惠券", "pixel_detect_coupon_popup_enabled_var", True),
("购物红包(默认关)", "pixel_detect_shopping_redpacket_enabled_var", False),
("开奖结果", "pixel_detect_lottery_result_enabled_var", True),
("参与按钮", "pixel_detect_attend_button_enabled_var", True),
("粉丝团", "pixel_detect_fansclub_join_enabled_var", True),
("福袋详情", "pixel_detect_fudai_detail_enabled_var", True),
("直播间", "pixel_detect_live_room_enabled_var", True),
("开奖结果OCR", "ocr_lottery_result_enabled_var", True),
("优惠券OCR", "ocr_coupon_popup_enabled_var", True),
("购物红包OCR(默认关)", "ocr_shopping_redpacket_enabled_var", False),
("页面OCR", "ocr_stage_page_enabled_var", True),
])
pack_fields(box, ctx, [
("福袋模板匹配阈值", "fudai_template_match_threshold_var", cfg_get(data.cfg, "fudai_template_match_threshold")),
("详情页模板匹配阈值", "fudai_detail_template_threshold_var", cfg_get(data.cfg, "fudai_detail_template_threshold")),
("开奖页红色占比阈值", "lucky_draw_red_ratio_threshold_var", cfg_get(data.cfg, "lucky_draw_red_ratio_threshold")),
("优惠券模板匹配阈值", "coupon_template_match_threshold_var", cfg_get(data.cfg, "coupon_template_match_threshold")),
("参与按钮红色占比阈值", "attend_button_red_ratio_threshold_var", cfg_get(data.cfg, "attend_button_red_ratio_threshold")),
("粉丝团加入红色占比阈值", "fansclub_join_red_ratio_threshold_var", cfg_get(data.cfg, "fansclub_join_red_ratio_threshold")),
("购物红包背景红色占比阈值", "shopping_redpacket_red_ratio_threshold_var", cfg_get(data.cfg, "shopping_redpacket_red_ratio_threshold")),
("详情主体蓝紫比例阈值", "fudai_detail_body_bluepurple_threshold_var", cfg_get(data.cfg, "fudai_detail_body_bluepurple_threshold")),
("暗色比例阈值", "fudai_detail_body_dark_threshold_var", cfg_get(data.cfg, "fudai_detail_body_dark_threshold")),
("达成形状匹配阈值", "fudai_task_status_template_threshold_var", cfg_get(data.cfg, "fudai_task_status_template_threshold")),
])
def _diagnostics(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
box = card(parent, "鼠标与阶段诊断")
box.pack(fill="x", pady=(0, 12))
pack_switches(box, ctx, [("详细阶段诊断日志", "stage_diag_verbose_var", False)])
pack_fields(box, ctx, [
("滑动速度(毫秒)", "swipe_duration_ms_var", cfg_get(data.cfg, "swipe_duration_ms")),
("上滑起始Y坐标", "swipe_up_start_y_var", cfg_get(data.cfg, "swipe_up_start_y")),
("上滑结束Y坐标", "swipe_up_end_y_var", cfg_get(data.cfg, "swipe_up_end_y")),
("最大诊断时间(秒)", "stage_diag_max_time_var", cfg_get(data.cfg, "stage_diag_max_time")),
("每步最大耗时(秒)", "stage_diag_max_step_time_var", cfg_get(data.cfg, "stage_diag_max_step_time")),
])
+78
View File
@@ -0,0 +1,78 @@
from __future__ import annotations
import tkinter as tk
from . import theme
from .page_context import PageContext
from .widgets import card, field, switch_row
def pack_fields(
parent: tk.Misc,
ctx: PageContext,
items: list[tuple[str, str, object]],
columns: int = 2,
) -> None:
grid = tk.Frame(parent, bg=theme.SURFACE)
grid.pack(fill="x", padx=12, pady=(3, 12))
for col in range(columns):
grid.grid_columnconfigure(col, weight=1, uniform="field")
for idx, (label, var_name, fallback) in enumerate(items):
cell = field(grid, label, ctx.var(var_name), value=fallback)
cell.grid(row=idx // columns, column=idx % columns, sticky="ew", padx=5, pady=4)
def pack_switches(
parent: tk.Misc,
ctx: PageContext,
items: list[tuple[str, str, bool]],
columns: int = 3,
) -> None:
grid = tk.Frame(parent, bg=theme.SURFACE)
grid.pack(fill="x", padx=12, pady=(3, 12))
for col in range(columns):
grid.grid_columnconfigure(col, weight=1, uniform="switch")
for idx, (label, var_name, fallback) in enumerate(items):
cell = switch_row(grid, label, ctx.var(var_name), fallback)
cell.grid(row=idx // columns, column=idx % columns, sticky="ew", padx=5, pady=4)
def text_box(
parent: tk.Misc,
ctx: PageContext,
key: str,
title: str,
initial: list[str],
height: int = 7,
) -> tk.Text:
box = card(parent, title)
box.pack(fill="both", expand=True, pady=(0, 12))
text = tk.Text(
box,
height=height,
bd=0,
bg=theme.SURFACE_ALT,
fg=theme.TEXT,
insertbackground=theme.TEAL,
font=theme.FONT_UI,
padx=9,
pady=8,
)
text.pack(fill="both", expand=True, padx=11, pady=(4, 11))
text.insert("1.0", "\n".join(str(x) for x in initial))
ctx.texts[key] = text
return text
def reservation_rows(data) -> list[dict]:
rows = []
for idx, item in enumerate(data.reservations[:24], 1):
rows.append({
"idx": idx,
"title": item.get("room_title") or item.get("title") or item.get("live_title") or "-",
"content": item.get("content") or item.get("prize_content") or item.get("gift") or "-",
"value": item.get("prize_value_yuan") or item.get("value") or "-",
"status": item.get("status") or item.get("state") or "等待中",
"time": item.get("target_ts") or item.get("created_ts") or item.get("updated_ts") or "-",
})
return rows
+64
View File
@@ -0,0 +1,64 @@
from __future__ import annotations
import tkinter as tk
from . import theme
from .data import DashboardData, fmt_ts
from .page_context import PageContext
from .page_helpers import reservation_rows
from .widgets import card, flow_grid, mini_table, section, stat_tile, table_panel, text_panel
def build_home(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "数据看板", "运行状态 / 截图 / 队列 / 记录")
metrics = flow_grid(parent, 3)
values = [
("运行日志", len(data.run_log), "最近记录", theme.TEAL, theme.TEAL_SOFT),
("行为日志", len(data.action_log), "动作流", theme.BLUE, theme.BLUE_SOFT),
("预约队列", len(data.reservations), "等待处理", theme.AMBER, theme.AMBER_SOFT),
("高价值房间", len(data.high_value_rooms), "本地记录", theme.GREEN, theme.GREEN_SOFT),
("中奖截图", len(data.win_images), "pic/lottery", theme.RED, theme.RED_SOFT),
("映射条目", len(data.mapping_rows), "room_pos", theme.TEAL_DARK, theme.TEAL_SOFT),
]
for idx, item in enumerate(values):
stat_tile(metrics, *item[:3], color=item[3], soft=item[4]).grid(row=idx // 3, column=idx % 3, sticky="ew", padx=5, pady=5)
body = tk.Frame(parent, bg=theme.BG)
body.pack(fill="both", expand=True)
body.grid_columnconfigure(0, weight=1, minsize=520)
body.grid_columnconfigure(1, weight=0, minsize=320)
left = tk.Frame(body, bg=theme.BG)
right = tk.Frame(body, bg=theme.BG)
left.grid(row=0, column=0, sticky="nsew", padx=(0, 8))
right.grid(row=0, column=1, sticky="nsew", padx=(8, 0))
rows = reservation_rows(data)
for row in rows:
row["time"] = fmt_ts(row["time"])
table_panel(left, "预约队列", (
("idx", "#", 28), ("title", "直播间", 110), ("content", "内容", 180),
("value", "价值", 52), ("status", "状态", 58), ("time", "时间", 96),
), rows, height=8).pack(fill="both", expand=True, pady=(0, 12))
high_rows = []
for item in data.high_value_rooms[:8]:
high_rows.append((
str(item.get("room_title") or item.get("title") or "-")[:18],
str(item.get("prize_value_yuan") or item.get("value") or "-"),
str(item.get("status") or "已记录"),
))
mini_table(left, "高价值房间", high_rows, color=theme.GREEN).pack(fill="x", pady=(0, 12))
text_panel(left, "运行日志", data.run_log[-80:], height=9).pack(fill="both", expand=True)
snap = card(right, "当前截图")
snap.pack(fill="x", pady=(0, 12))
snap_name = data.screenshot_path.name if data.screenshot_path else "暂无截图"
tk.Label(snap, text=snap_name, bg="#fbfcfa", fg=theme.TEXT, font=theme.FONT_UI, anchor="w").pack(fill="x", padx=12, pady=(4, 6))
tk.Label(snap, text="完整预览请打开“截图预览”界面", bg=theme.TEAL_SOFT, fg=theme.TEAL_DARK, font=theme.FONT_SMALL, padx=8, pady=3).pack(anchor="w", padx=12, pady=(0, 12))
text_panel(right, "实时动作", data.action_log[-80:], height=9).pack(fill="both", expand=True)
def build_statistics(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "统计信息", "本地运行统计看板")
build_home(parent, data, ctx)
+49
View File
@@ -0,0 +1,49 @@
from __future__ import annotations
from .page_config import (
build_filter_settings,
build_keywords,
build_license,
build_logging,
build_reservation_settings,
build_run_settings,
build_yanghao_settings,
)
from .page_data import (
build_actions_log,
build_high_value,
build_mapping,
build_ocr,
build_preview,
build_realtime,
build_reservation_queue,
build_run_log,
build_wifi_adb,
build_wins,
)
from .page_debug import build_debug_settings
from .page_home import build_home, build_statistics
PAGES = {
"数据看板": build_home,
"运行设置": build_run_settings,
"筛选设置": build_filter_settings,
"高价值预约": build_reservation_settings,
"养号设置": build_yanghao_settings,
"调试参数": build_debug_settings,
"授权": build_license,
"日志配置": build_logging,
"关键词": build_keywords,
"运行日志": build_run_log,
"截图预览": build_preview,
"统计信息": build_statistics,
"预约队列": build_reservation_queue,
"高价值房间": build_high_value,
"行为日志": build_actions_log,
"实时状态": build_realtime,
"OCR结果": build_ocr,
"中奖记录": build_wins,
"映射表": build_mapping,
"WiFi ADB": build_wifi_adb,
}
-350
View File
@@ -1,350 +0,0 @@
from __future__ import annotations
import tkinter as tk
from pathlib import Path
from tkinter import ttk
from . import theme
from .data import DashboardData, cfg_get, fmt_ts
from .widgets import card, field, flow_grid, metric, preview_panel, section, switch_row, table_panel, text_panel
def _pack_fields(parent, items: list[tuple[str, object]], columns: int = 2) -> None:
grid = tk.Frame(parent, bg=theme.SURFACE)
grid.pack(fill="x", padx=14, pady=(4, 14))
for col in range(columns):
grid.grid_columnconfigure(col, weight=1, uniform="field")
for idx, (label, value) in enumerate(items):
cell = field(grid, label, value)
cell.grid(row=idx // columns, column=idx % columns, sticky="ew", padx=8, pady=5)
def _sample_reservation_rows(data: DashboardData) -> list[dict]:
rows = []
for idx, item in enumerate(data.reservations[:18], 1):
rows.append({
"idx": idx,
"title": item.get("room_title") or item.get("title") or item.get("live_title") or "-",
"content": item.get("content") or item.get("prize_content") or item.get("gift") or "-",
"value": item.get("prize_value_yuan") or item.get("value") or "-",
"status": item.get("status") or item.get("state") or "等待中",
"time": fmt_ts(item.get("target_ts") or item.get("created_ts") or item.get("updated_ts")),
})
return rows
def build_home(parent, data: DashboardData) -> None:
section(parent, "数据看板", "现有统计 / 实时状态 / 队列 / 截图集中视图")
metrics = flow_grid(parent, 6)
values = [
("运行日志", len(data.run_log), "最近记录", theme.TEAL),
("行为日志", len(data.action_log), "最近行为", theme.BLUE),
("预约队列", len(data.reservations), "等待处理", theme.AMBER),
("高价值房间", len(data.high_value_rooms), "本地记录", theme.GREEN),
("中奖截图", len(data.win_images), "pic/lottery", theme.RED),
("映射条目", len(data.mapping_rows), "room_pos", theme.TEAL_DARK),
]
for idx, item in enumerate(values):
metric(metrics, *item).grid(row=0, column=idx, sticky="ew", padx=5)
body = tk.Frame(parent, bg=theme.BG)
body.pack(fill="both", expand=True)
body.grid_columnconfigure(0, weight=7)
body.grid_columnconfigure(1, weight=4)
body.grid_rowconfigure(0, weight=1)
left = tk.Frame(body, bg=theme.BG)
right = tk.Frame(body, bg=theme.BG)
left.grid(row=0, column=0, sticky="nsew", padx=(0, 8))
right.grid(row=0, column=1, sticky="nsew", padx=(8, 0))
table_panel(left, "预约队列", (
("idx", "#", 40), ("title", "直播间", 180), ("content", "内容", 220),
("value", "价值", 80), ("status", "状态", 90), ("time", "时间", 150),
), _sample_reservation_rows(data), height=8).pack(fill="both", expand=True, pady=(0, 12))
text_panel(left, "运行日志", data.run_log[-80:], height=11).pack(fill="both", expand=True)
preview_panel(right, data.screenshot_path).pack(fill="both", expand=True, pady=(0, 12))
text_panel(right, "实时动作", data.action_log[-80:], height=9).pack(fill="both", expand=True)
def build_run_settings(parent, data: DashboardData) -> None:
section(parent, "运行设置", "运行时长、切换、滑动回退与直播间进入策略")
box = card(parent, "核心运行参数")
box.pack(fill="x")
_pack_fields(box, [
("允许切换直播间", cfg_get(data.cfg, "needswitch")),
("无限循环模式", cfg_get(data.cfg, "infinite_loop_enabled")),
("运行时长(分钟)", cfg_get(data.cfg, "wait_minutes")),
("倒计时大于不参与", cfg_get(data.cfg, "skip_if_countdown_gt_seconds")),
("倒计时小于不参与", cfg_get(data.cfg, "skip_if_countdown_lt_seconds")),
("滑动次数限制", cfg_get(data.cfg, "reset_after_swipes_enabled")),
("次数", cfg_get(data.cfg, "reset_after_swipes")),
("回退方式", cfg_get(data.cfg, "reset_after_swipes_action")),
("进入坐标模式", cfg_get(data.cfg, "reenter_live_entry_mode")),
("连续无福袋退出阈值", cfg_get(data.cfg, "fudai_exit_after_misses")),
])
def build_filter_settings(parent, data: DashboardData) -> None:
section(parent, "筛选设置", "价值、人数、倒计时与粉丝团策略")
box = card(parent, "筛选规则")
box.pack(fill="x")
_pack_fields(box, [
("最低价值(元)", cfg_get(data.cfg, "min_prize_value_yuan")),
("参与人数最小", cfg_get(data.cfg, "min_participants")),
("参与人数最大", cfg_get(data.cfg, "max_participants")),
("倒计时小于不参与", cfg_get(data.cfg, "skip_if_countdown_lt_seconds")),
("粉丝团失败策略", cfg_get(data.cfg, "fansclub_fail_action")),
("粉丝团点击延迟(s)", cfg_get(data.cfg, "fansclub_click_delay")),
("自动加入等待(s)", cfg_get(data.cfg, "fansclub_auto_join_wait_seconds")),
("手动加入等待(s)", cfg_get(data.cfg, "fansclub_manual_wait_seconds")),
])
def build_reservation_settings(parent, data: DashboardData) -> None:
section(parent, "高价值预约", "高价值记录、回访与回退校验")
box = card(parent, "预约策略")
box.pack(fill="x")
_pack_fields(box, [
("启用高价值预约", cfg_get(data.cfg, "high_value_fudai_enabled")),
("价值阈值(元)", cfg_get(data.cfg, "high_value_fudai_threshold_yuan")),
("提前参与(秒)", cfg_get(data.cfg, "high_value_fudai_join_ahead_seconds")),
("最多回退次数", cfg_get(data.cfg, "high_value_fudai_max_swipe_back")),
("最多记录数量", cfg_get(data.cfg, "high_value_fudai_max_reservations")),
("完成后策略", cfg_get(data.cfg, "high_value_fudai_after_action")),
("启用高价值房间回访", cfg_get(data.cfg, "high_value_room_revisit_enabled")),
("重访最小间隔(秒)", cfg_get(data.cfg, "high_value_room_revisit_min_interval_seconds")),
("每次运行最大次数", cfg_get(data.cfg, "high_value_room_revisit_max_per_run")),
("最低奖品价值(元)", cfg_get(data.cfg, "high_value_room_revisit_min_prize_value")),
("最大年龄(天)", cfg_get(data.cfg, "high_value_room_revisit_max_age_days")),
("开奖前轮询(秒)", cfg_get(data.cfg, "high_value_fudai_poll_before_seconds")),
("回退滑延迟(秒)", cfg_get(data.cfg, "reservation_back_swipe_delay")),
("校验等待时间(秒)", cfg_get(data.cfg, "reservation_back_verify_wait_seconds")),
])
def build_yanghao_settings(parent, data: DashboardData) -> None:
section(parent, "养号设置", "推荐流停留、互动概率与关键词")
metrics = flow_grid(parent, 4)
for idx, item in enumerate([
("养号启用", cfg_get(data.cfg, "yanghao_enabled"), "开关", theme.TEAL),
("推荐停留", cfg_get(data.cfg, "yanghao_recommend_duration_seconds"), "秒", theme.BLUE),
("点赞概率", cfg_get(data.cfg, "yanghao_like_prob"), "0-1", theme.AMBER),
("收藏概率", cfg_get(data.cfg, "yanghao_fav_prob"), "0-1", theme.GREEN),
]):
metric(metrics, *item).grid(row=0, column=idx, sticky="ew", padx=5)
box = card(parent, "互动参数")
box.pack(fill="x")
_pack_fields(box, [
("启用互动动作", cfg_get(data.cfg, "yanghao_enable_actions")),
("只养号模式", cfg_get(data.cfg, "yanghao_only")),
("评论概率", cfg_get(data.cfg, "yanghao_comment_prob")),
("动作停留最小(s)", cfg_get(data.cfg, "yanghao_dwell_on_action_min_seconds")),
("动作停留最大(s)", cfg_get(data.cfg, "yanghao_dwell_on_action_max_seconds")),
("图标匹配阈值", cfg_get(data.cfg, "yanghao_icon_match_threshold")),
])
def build_debug_settings(parent, data: DashboardData) -> None:
section(parent, "调试参数", "识别阈值、模板匹配、像素检测与截图调试")
metrics = flow_grid(parent, 4)
for idx, item in enumerate([
("调试截图", cfg_get(data.cfg, "debug_captures", "enabled"), "enabled", theme.TEAL),
("保留天数", cfg_get(data.cfg, "debug_captures", "keep_days"), "debug", theme.BLUE),
("最大文件", cfg_get(data.cfg, "debug_captures", "max_files"), "cleanup", theme.AMBER),
("OCR模式", cfg_get(data.cfg, "fudai_detail_ui_mode"), "detail", theme.GREEN),
]):
metric(metrics, *item).grid(row=0, column=idx, sticky="ew", padx=5)
box = card(parent, "识别与点击参数")
box.pack(fill="x")
_pack_fields(box, [
("找福袋最大尝试", cfg_get(data.cfg, "fudai_find_max_attempts")),
("找福袋重试间隔", cfg_get(data.cfg, "fudai_icon_retry_delay_seconds")),
("最大等待时间", cfg_get(data.cfg, "fudai_icon_max_wait_seconds")),
("点击后等待", cfg_get(data.cfg, "fudai_click_wait_seconds")),
("模板匹配阈值", cfg_get(data.cfg, "fudai_template_match_threshold")),
("详情模板阈值", cfg_get(data.cfg, "fudai_detail_template_threshold")),
("开奖页红色阈值", cfg_get(data.cfg, "lucky_draw_red_ratio_threshold")),
("滑动速度(ms)", cfg_get(data.cfg, "swipe_duration_ms")),
])
def build_license(parent, data: DashboardData) -> None:
section(parent, "授权", "卡密授权、本机机器码与授权文件")
box = card(parent, "卡密授权")
box.pack(fill="x")
_pack_fields(box, [
("授权状态", "本地检测"),
("本机机器码", ""),
("授权文件", "license.dat"),
("输入卡密", ""),
], columns=1)
ttk.Button(box, text="安装卡密", style="Primary.TButton").pack(side="left", padx=22, pady=(0, 18))
ttk.Button(box, text="刷新状态", style="Soft.TButton").pack(side="left", padx=6, pady=(0, 18))
def build_logging(parent, data: DashboardData) -> None:
section(parent, "日志配置", "日志格式、保留策略、实时状态刷新")
box = card(parent, "日志与界面")
box.pack(fill="x")
_pack_fields(box, [
("日志格式模式", cfg_get(data.cfg, "logging", "log_format_mode")),
("统一日志路径", cfg_get(data.cfg, "log_unified_path")),
("保留天数", cfg_get(data.cfg, "logging", "keep_days")),
("总量上限(GB)", cfg_get(data.cfg, "logging", "max_total_size_gb")),
("压缩阈值(天)", cfg_get(data.cfg, "logging", "compress_after_days")),
("警告阈值(MB)", cfg_get(data.cfg, "logging", "monitor_warning_mb")),
("严重阈值(MB)", cfg_get(data.cfg, "logging", "monitor_critical_mb")),
("界面主题", cfg_get(data.cfg, "gui", "theme")),
("实时刷新(ms)", cfg_get(data.cfg, "gui", "realtime_status", "refresh_interval_ms")),
("实时状态条数", cfg_get(data.cfg, "gui", "realtime_status", "tail_items")),
])
def build_keywords(parent, data: DashboardData) -> None:
section(parent, "关键词", "白名单与黑名单")
body = tk.Frame(parent, bg=theme.BG)
body.pack(fill="both", expand=True)
for idx, title in enumerate(("想要 contains_want(白名单,空=不限制)", "不想要 contains_not_want(黑名单)")):
box = card(body, title)
box.grid(row=0, column=idx, sticky="nsew", padx=(0, 8) if idx == 0 else (8, 0))
text = tk.Text(box, height=18, bd=0, bg="#fbfcfa", font=theme.FONT_UI)
text.pack(fill="both", expand=True, padx=12, pady=(4, 12))
body.grid_columnconfigure(0, weight=1)
body.grid_columnconfigure(1, weight=1)
body.grid_rowconfigure(0, weight=1)
def build_run_log(parent, data: DashboardData) -> None:
section(parent, "运行日志", "筛选 / 搜索 / 刷新")
text_panel(parent, "最近运行日志", data.run_log, height=24).pack(fill="both", expand=True)
def build_preview(parent, data: DashboardData) -> None:
section(parent, "截图预览", "选择图片 / 打开pic目录 / 刷新预览")
preview_panel(parent, data.screenshot_path, "当前截图").pack(fill="both", expand=True)
def build_statistics(parent, data: DashboardData) -> None:
section(parent, "统计信息", "本地运行统计看板")
build_home(parent, data)
def build_reservation_queue(parent, data: DashboardData) -> None:
section(parent, "预约队列", "预约队列总览与等待状态")
table_panel(parent, "预约队列", (
("idx", "#", 40), ("title", "直播间", 190), ("content", "内容", 250),
("value", "价值", 80), ("status", "状态", 90), ("time", "时间", 170),
), _sample_reservation_rows(data), height=18).pack(fill="both", expand=True)
def build_high_value(parent, data: DashboardData) -> None:
section(parent, "高价值房间", "持久化高价值记录")
rows = []
for idx, item in enumerate(data.high_value_rooms[:50], 1):
rows.append({
"idx": idx,
"title": item.get("room_title") or item.get("title") or "-",
"content": item.get("content") or item.get("prize_content") or "-",
"value": item.get("prize_value_yuan") or item.get("value") or "-",
"status": item.get("status") or "已记录",
})
table_panel(parent, "高价值房间", (
("idx", "#", 40), ("title", "直播间", 220), ("content", "内容", 280),
("value", "价值", 90), ("status", "状态", 100),
), rows, height=20).pack(fill="both", expand=True)
def build_actions_log(parent, data: DashboardData) -> None:
section(parent, "行为日志", "关键字筛选 / 搜索 / 刷新")
text_panel(parent, "最近行为日志", data.action_log, height=24).pack(fill="both", expand=True)
def build_realtime(parent, data: DashboardData) -> None:
section(parent, "实时状态", "显示动作流 / 显示截图 / 自动滚动 / 查看大图")
body = tk.Frame(parent, bg=theme.BG)
body.pack(fill="both", expand=True)
body.grid_columnconfigure(0, weight=5)
body.grid_columnconfigure(1, weight=3)
text_panel(body, "动作流", data.action_log[-120:], height=24).grid(row=0, column=0, sticky="nsew", padx=(0, 8))
preview_panel(body, data.screenshot_path, "实时截图").grid(row=0, column=1, sticky="nsew", padx=(8, 0))
def build_ocr(parent, data: DashboardData) -> None:
section(parent, "OCR结果", "点击 截图+OCR 后更新")
lines = []
for p in data.ocr_files[:8]:
lines.append(f"{p.name} {fmt_ts(p.stat().st_mtime)}")
text_panel(parent, "OCR结果", lines or ['暂无OCR结果,请先点击"截图+OCR"按钮'], height=24).pack(fill="both", expand=True)
def build_wins(parent, data: DashboardData) -> None:
section(parent, "中奖记录", "中奖截图列表与预览")
body = tk.Frame(parent, bg=theme.BG)
body.pack(fill="both", expand=True)
body.grid_columnconfigure(0, weight=4)
body.grid_columnconfigure(1, weight=5)
rows = [
{"idx": i + 1, "file": p.name, "time": fmt_ts(p.stat().st_mtime)}
for i, p in enumerate(data.win_images[:40])
]
table_panel(body, "中奖截图", (("idx", "#", 40), ("file", "文件", 260), ("time", "时间", 160)), rows, height=18).grid(row=0, column=0, sticky="nsew", padx=(0, 8))
preview_panel(body, data.win_images[0] if data.win_images else None, "中奖预览").grid(row=0, column=1, sticky="nsew", padx=(8, 0))
def build_mapping(parent, data: DashboardData) -> None:
section(parent, "映射表", "显示原始标题 / 刷新映射表 / 搜索 / 复制条目")
table_panel(parent, "运行时映射表", (
("pos", "位置", 80), ("title", "标题", 360), ("status", "状态", 100), ("updated", "更新时间", 180),
), data.mapping_rows, height=22).pack(fill="both", expand=True)
def build_wifi_adb(parent, data: DashboardData) -> None:
section(parent, "WiFi ADB", "扫描 WiFi / USB 授权提示 / 连接状态")
metrics = flow_grid(parent, 4)
for idx, item in enumerate([
("USB设备", "待检测", "首次启用", theme.TEAL),
("扫描状态", "未扫描", "局域网", theme.BLUE),
("默认端口", "5555", "ADB TCP", theme.AMBER),
("当前设备", "自动选择", "设备选择器", theme.GREEN),
]):
metric(metrics, *item).grid(row=0, column=idx, sticky="ew", padx=5)
rows = [
{"device": "待扫描设备", "ip": "192.168.1.x", "port": "5555", "state": "未连接"},
]
table_panel(parent, "WiFi 设备列表", (
("device", "设备ID", 220), ("ip", "IP地址", 180), ("port", "端口", 90), ("state", "状态", 120),
), rows, height=8).pack(fill="x", pady=(0, 12))
box = card(parent, "连接操作")
box.pack(fill="x")
row = tk.Frame(box, bg=theme.SURFACE)
row.pack(fill="x", padx=14, pady=14)
ttk.Button(row, text="扫描WiFi", style="Primary.TButton").pack(side="left", padx=(0, 8))
ttk.Button(row, text="刷新", style="Soft.TButton").pack(side="left", padx=4)
ttk.Button(row, text="连接", style="Soft.TButton").pack(side="left", padx=4)
ttk.Button(row, text="取消", style="Soft.TButton").pack(side="left", padx=4)
ttk.Label(row, text="请确保设备已通过 USB 授权,并已开启无线调试/ADB TCP。", style="Small.TLabel").pack(side="left", padx=14)
PAGES = {
"数据看板": build_home,
"运行设置": build_run_settings,
"筛选设置": build_filter_settings,
"高价值预约": build_reservation_settings,
"养号设置": build_yanghao_settings,
"调试参数": build_debug_settings,
"授权": build_license,
"日志配置": build_logging,
"关键词": build_keywords,
"运行日志": build_run_log,
"截图预览": build_preview,
"统计信息": build_statistics,
"预约队列": build_reservation_queue,
"高价值房间": build_high_value,
"行为日志": build_actions_log,
"实时状态": build_realtime,
"OCR结果": build_ocr,
"中奖记录": build_wins,
"映射表": build_mapping,
"WiFi ADB": build_wifi_adb,
}
+69 -22
View File
@@ -3,24 +3,38 @@ from __future__ import annotations
from tkinter import ttk
BG = "#f6f7f4"
SURFACE = "#ffffff"
SURFACE_ALT = "#f1f5f2"
BORDER = "#dfe7e2"
TEXT = "#1f2a2a"
MUTED = "#6d7a7a"
TEAL = "#009688"
TEAL_DARK = "#00796b"
AMBER = "#f59e0b"
RED = "#ef4444"
GREEN = "#16a34a"
BLUE = "#3b82f6"
BG = "#f5f6f2"
BG_ALT = "#edf1eb"
SURFACE = "#fffefd"
SURFACE_ALT = "#f8faf7"
SURFACE_HOVER = "#f1f6f2"
BORDER = "#dde5dd"
BORDER_DARK = "#c8d4cb"
TEXT = "#111f1c"
MUTED = "#61716d"
SUBTLE = "#96a39f"
TEAL = "#078a7c"
TEAL_DARK = "#066d62"
TEAL_SOFT = "#e2f3ef"
AMBER = "#a86d00"
AMBER_SOFT = "#fff2d7"
RED = "#ca4747"
RED_SOFT = "#fff0ee"
GREEN = "#16834b"
GREEN_SOFT = "#e6f4eb"
BLUE = "#336fd0"
BLUE_SOFT = "#edf4ff"
SHADOW = "#e8ede8"
FONT_UI = ("Microsoft YaHei UI", 10)
FONT_SMALL = ("Microsoft YaHei UI", 9)
FONT_TITLE = ("Microsoft YaHei UI", 15, "bold")
FONT_H2 = ("Microsoft YaHei UI", 12, "bold")
FONT_MONO = ("Consolas", 10)
RADIUS_SM = 8
RADIUS_MD = 12
RADIUS_LG = 16
FONT_UI = ("Microsoft YaHei UI", 9)
FONT_SMALL = ("Microsoft YaHei UI", 8)
FONT_TITLE = ("Microsoft YaHei UI", 14, "bold")
FONT_H2 = ("Microsoft YaHei UI", 10, "bold")
FONT_MONO = ("Consolas", 8)
def setup_styles(root) -> None:
@@ -33,21 +47,54 @@ def setup_styles(root) -> None:
style.configure(".", font=FONT_UI)
style.configure("Dashboard.TFrame", background=BG)
style.configure("Toolbar.TFrame", background=SURFACE)
style.configure("Surface.TFrame", background=SURFACE)
style.configure("Alt.TFrame", background=SURFACE_ALT)
style.configure("Card.TFrame", background=SURFACE, borderwidth=1, relief="solid")
style.configure("Muted.TLabel", background=SURFACE, foreground=MUTED, font=FONT_SMALL)
style.configure("Title.TLabel", background=BG, foreground=TEXT, font=FONT_TITLE)
style.configure("H2.TLabel", background=SURFACE, foreground=TEXT, font=FONT_H2)
style.configure("Value.TLabel", background=SURFACE, foreground=TEXT, font=("Microsoft YaHei UI", 18, "bold"))
style.configure("Value.TLabel", background=SURFACE, foreground=TEXT, font=("Microsoft YaHei UI", 17, "bold"))
style.configure("Small.TLabel", background=SURFACE, foreground=MUTED, font=FONT_SMALL)
style.configure("Sidebar.TButton", padding=(12, 8), anchor="w")
style.configure("Primary.TButton", padding=(14, 8), foreground="#ffffff", background=TEAL)
style.configure("Primary.TButton", padding=(14, 8), foreground="#ffffff", background=TEAL, borderwidth=0)
style.map("Primary.TButton", background=[("active", TEAL_DARK)])
style.configure("Danger.TButton", padding=(14, 8), foreground=RED)
style.configure("Soft.TButton", padding=(12, 7))
style.configure("Dashboard.TNotebook", background=BG, borderwidth=0)
style.configure("Dashboard.TNotebook.Tab", padding=(14, 8), font=FONT_SMALL)
style.configure("Treeview", font=FONT_SMALL, rowheight=28, background=SURFACE, fieldbackground=SURFACE)
style.configure("Treeview.Heading", font=("Microsoft YaHei UI", 9, "bold"))
style.configure(
"Treeview",
font=("Microsoft YaHei UI", 8),
rowheight=23,
background=SURFACE,
fieldbackground=SURFACE,
borderwidth=0,
relief="flat",
)
style.map("Treeview", background=[("selected", TEAL_SOFT)], foreground=[("selected", TEXT)])
style.configure(
"Treeview.Heading",
font=("Microsoft YaHei UI", 8, "bold"),
background="#eef2eb",
foreground=TEXT,
relief="flat",
)
style.configure(
"TCombobox",
fieldbackground=SURFACE_ALT,
background=SURFACE,
foreground=TEXT,
bordercolor=BORDER,
arrowcolor=MUTED,
padding=(8, 4),
)
style.configure(
"TSpinbox",
fieldbackground=SURFACE_ALT,
background=SURFACE,
foreground=TEXT,
bordercolor=BORDER,
arrowcolor=MUTED,
padding=(6, 3),
)
+299 -36
View File
@@ -4,46 +4,258 @@ import os
import tkinter as tk
from pathlib import Path
from tkinter import ttk
from typing import Iterable, Sequence
from typing import Callable, Iterable, Sequence
from . import theme
BUTTON_ICONS = {
"刷新设备": "⟳",
"扫描 WiFi": "⌕",
"扫描WiFi": "⌕",
"WiFi ADB": "▣",
"保存配置": "✓",
"截图+OCR": "▧",
"开始运行": "▶",
"停止": "■",
"强制停止": "!",
"发送返回键": "↩",
"刷新": "⟳",
"刷新预览": "⟳",
"刷新列表": "⟳",
"刷新映射表": "⟳",
"打开pic目录": "□",
"打开目录": "□",
"安装卡密": "✓",
"刷新状态": "⟳",
"保存日志配置": "✓",
"查看大图": "▢",
"复制条目": "◇",
"清除": "×",
}
NAV_ICONS = {
"数据看板": "▦",
"运行设置": "▶",
"筛选设置": "◈",
"高价值预约": "◇",
"养号设置": "◌",
"调试参数": "⌁",
"授权": "✓",
"日志配置": "☰",
"关键词": "⌕",
"运行日志": "☰",
"截图预览": "▧",
"统计信息": "▦",
"预约队列": "≡",
"高价值房间": "◇",
"行为日志": "☷",
"实时状态": "●",
"OCR结果": "▤",
"中奖记录": "□",
"映射表": "⌘",
"WiFi ADB": "▣",
}
def _with_icon(text: str, icon: str | None) -> str:
if not icon:
return text
return text if text.startswith(icon) else f"{icon} {text}"
def _parent_bg(parent) -> str:
try:
return str(parent["bg"])
except Exception:
return theme.BG
class IconButton(tk.Button):
def __init__(self, *args, icon: str | None = None, **kwargs):
self._icon = icon
if "text" in kwargs:
kwargs["text"] = _with_icon(str(kwargs["text"]), icon)
super().__init__(*args, **kwargs)
def configure(self, cnf=None, **kwargs): # type: ignore[override]
if "text" in kwargs:
kwargs["text"] = _with_icon(str(kwargs["text"]), self._icon)
return super().configure(cnf, **kwargs)
config = configure
def rounded_rect(canvas: tk.Canvas, x1: int, y1: int, x2: int, y2: int, radius: int, **kwargs) -> int:
points = [
x1 + radius, y1,
x2 - radius, y1,
x2, y1,
x2, y1 + radius,
x2, y2 - radius,
x2, y2,
x2 - radius, y2,
x1 + radius, y2,
x1, y2,
x1, y2 - radius,
x1, y1 + radius,
x1, y1,
]
return canvas.create_polygon(points, smooth=True, splinesteps=16, **kwargs)
class RoundedButton(tk.Canvas):
def __init__(
self,
parent,
text: str,
command: Callable[[], None] | None,
*,
kind: str = "soft",
icon: str | None = None,
width: int | None = None,
) -> None:
self._icon = icon
self.text = _with_icon(text, icon)
self.command = command
self.kind = kind
self._state = "normal"
colors = {
"primary": (theme.TEAL, "#ffffff", theme.TEAL_DARK),
"danger": (theme.RED_SOFT, theme.RED, "#ffe5e2"),
"amber": (theme.AMBER_SOFT, "#8a5a00", "#ffe8b8"),
"soft": (theme.SURFACE_ALT, theme.TEXT, theme.SURFACE_HOVER),
"ghost": (theme.SURFACE, theme.TEXT, theme.TEAL_SOFT),
}
self.bg_color, self.fg_color, self.hover_color = colors.get(kind, colors["soft"])
w = width or max(78, len(self.text) * 12 + 24)
super().__init__(parent, width=w, height=30, bg=_parent_bg(parent), highlightthickness=0, bd=0, cursor="hand2")
self._draw(self.bg_color)
self.bind("<Button-1>", self._click)
self.bind("<Enter>", lambda _e: self._draw(self.hover_color))
self.bind("<Leave>", lambda _e: self._draw(self.bg_color))
def _draw(self, fill: str) -> None:
self.delete("all")
outline = theme.BORDER_DARK if self.kind == "primary" else theme.BORDER
fg = self.fg_color if self._state != "disabled" else theme.SUBTLE
rounded_rect(self, 1, 1, int(self["width"]) - 2, int(self["height"]) - 2, theme.RADIUS_SM, fill=fill, outline=outline)
self.create_text(int(self["width"]) // 2, int(self["height"]) // 2, text=self.text, fill=fg, font=("Microsoft YaHei UI", 8, "bold") if self.kind == "primary" else theme.FONT_SMALL)
def _click(self, _event) -> None:
if self.command and self._state != "disabled":
self.command()
def configure(self, cnf=None, **kwargs): # type: ignore[override]
if cnf:
kwargs.update(cnf)
if "text" in kwargs:
self.text = _with_icon(str(kwargs.pop("text")), self._icon)
if "state" in kwargs:
self._state = str(kwargs.pop("state"))
self.configure(cursor="arrow" if self._state == "disabled" else "hand2")
result = super().configure(**kwargs) if kwargs else None
self._draw(self.bg_color)
return result
config = configure
class RoundedNavButton(tk.Canvas):
def __init__(self, parent, text: str, command: Callable[[], None], *, active: bool = False) -> None:
self.raw_text = text
self.text = _with_icon(text, NAV_ICONS.get(text))
self.command = command
self.active = active
super().__init__(parent, height=27, bg=theme.SURFACE, highlightthickness=0, bd=0, cursor="hand2")
self.bind("<Configure>", lambda _e: self._draw())
self.bind("<Button-1>", lambda _e: self.command())
self.bind("<Enter>", lambda _e: self._draw(hover=True))
self.bind("<Leave>", lambda _e: self._draw())
def set_active(self, active: bool) -> None:
self.active = active
self._draw()
def _draw(self, hover: bool = False) -> None:
self.delete("all")
width = max(1, self.winfo_width())
bg = theme.TEAL_SOFT if self.active else (theme.SURFACE_HOVER if hover else theme.SURFACE)
fg = theme.TEAL_DARK if self.active else theme.TEXT
rounded_rect(self, 1, 2, width - 2, 25, theme.RADIUS_SM, fill=bg, outline=bg)
if self.active:
rounded_rect(self, 3, 7, 7, 20, 4, fill=theme.TEAL, outline=theme.TEAL)
self.create_text(15 if self.active else 11, 14, text=self.text, anchor="w", fill=fg, font=("Microsoft YaHei UI", 8, "bold") if self.active else theme.FONT_UI)
def clear(frame: tk.Misc) -> None:
for child in frame.winfo_children():
child.destroy()
def button(parent, text: str, command: Callable[[], None] | None = None, *, kind: str = "soft", width: int | None = None) -> tk.Canvas:
return RoundedButton(parent, text, command, kind=kind, icon=BUTTON_ICONS.get(text), width=width)
def nav_button(parent, text: str, command: Callable[[], None], *, active: bool = False) -> tk.Canvas:
return RoundedNavButton(parent, text, command, active=active)
def pill(parent, text: str, *, fg: str = theme.TEAL, bg: str = theme.TEAL_SOFT) -> tk.Label:
return tk.Label(parent, text=text, bg=bg, fg=fg, font=("Microsoft YaHei UI", 8, "bold"), padx=10, pady=3)
def status_pill(parent, text: str, *, color: str = theme.GREEN, bg: str = theme.GREEN_SOFT) -> tk.Label:
return tk.Label(parent, text=text, bg=bg, fg=color, font=("Microsoft YaHei UI", 8, "bold"), padx=12, pady=4)
def card(parent, title: str | None = None, *, padding: int = 14) -> tk.Frame:
frame = tk.Frame(parent, bg=theme.SURFACE, highlightbackground=theme.BORDER, highlightthickness=1)
if title:
ttk.Label(frame, text=title, style="H2.TLabel").pack(anchor="w", padx=padding, pady=(padding, 6))
head = tk.Frame(frame, bg=theme.SURFACE)
head.pack(fill="x", padx=padding, pady=(padding - 2, 5))
tk.Frame(head, bg=theme.TEAL, width=3, height=15).pack(side="left", padx=(0, 8))
ttk.Label(head, text=title, style="H2.TLabel").pack(side="left")
return frame
def metric(parent, title: str, value: object, hint: str = "", color: str = theme.TEAL) -> tk.Frame:
box = card(parent)
top = tk.Frame(box, bg=theme.SURFACE)
top.pack(fill="x", padx=14, pady=(12, 4))
top.pack(fill="x", padx=14, pady=(10, 3))
tk.Label(top, text="●", fg=color, bg=theme.SURFACE, font=("Segoe UI", 11, "bold")).pack(side="left")
ttk.Label(top, text=title, style="Small.TLabel").pack(side="left", padx=(6, 0))
ttk.Label(box, text=str(value), style="Value.TLabel").pack(anchor="w", padx=14)
ttk.Label(box, text=hint, style="Small.TLabel").pack(anchor="w", padx=14, pady=(0, 12))
ttk.Label(box, text=hint, style="Small.TLabel").pack(anchor="w", padx=14, pady=(0, 10))
return box
def stat_tile(parent, title: str, value: object, hint: str, *, color: str, soft: str) -> tk.Frame:
box = tk.Frame(parent, bg=theme.SURFACE, highlightbackground=theme.BORDER, highlightthickness=1)
accent = tk.Frame(box, bg=color, width=3)
accent.pack(side="left", fill="y")
inner = tk.Frame(box, bg=theme.SURFACE)
inner.pack(side="left", fill="both", expand=True)
head = tk.Frame(inner, bg=theme.SURFACE)
head.pack(fill="x", padx=13, pady=(9, 3))
tk.Label(head, text=title, bg=theme.SURFACE, fg=theme.MUTED, font=theme.FONT_SMALL).pack(side="left")
tk.Label(head, text="●", bg=theme.SURFACE, fg=color, font=("Segoe UI", 11, "bold")).pack(side="right")
tk.Label(inner, text=str(value), bg=theme.SURFACE, fg=theme.TEXT, font=("Microsoft YaHei UI", 16, "bold")).pack(anchor="w", padx=13)
tk.Label(inner, text=hint, bg=soft, fg=color, font=("Microsoft YaHei UI", 8, "bold"), padx=9, pady=2).pack(anchor="w", padx=13, pady=(4, 9))
return box
def section(parent, title: str, subtitle: str = "") -> tk.Frame:
row = tk.Frame(parent, bg=theme.BG)
row.pack(fill="x", pady=(0, 10))
row.pack(fill="x", pady=(0, 8))
ttk.Label(row, text=title, style="Title.TLabel").pack(side="left")
if subtitle:
ttk.Label(row, text=subtitle, background=theme.BG, foreground=theme.MUTED, font=theme.FONT_SMALL).pack(side="left", padx=(10, 0))
tk.Label(row, text=subtitle, bg=theme.TEAL_SOFT, fg=theme.TEAL_DARK, font=theme.FONT_SMALL, padx=9, pady=2).pack(side="left", padx=(10, 0))
return row
def flow_grid(parent, columns: int = 4) -> tk.Frame:
grid = tk.Frame(parent, bg=theme.BG)
grid.pack(fill="x", pady=(0, 14))
grid.pack(fill="x", pady=(0, 10))
for idx in range(columns):
grid.grid_columnconfigure(idx, weight=1, uniform="metric")
return grid
@@ -51,8 +263,8 @@ def flow_grid(parent, columns: int = 4) -> tk.Frame:
def text_panel(parent, title: str, lines: Iterable[str], height: int = 10) -> tk.Frame:
box = card(parent, title)
text = tk.Text(box, height=height, wrap="none", bd=0, bg="#fbfcfa", fg=theme.TEXT, insertbackground=theme.TEAL, font=theme.FONT_MONO)
text.pack(fill="both", expand=True, padx=12, pady=(4, 12))
text = tk.Text(box, height=height, wrap="none", bd=0, bg=theme.SURFACE_ALT, fg=theme.TEXT, insertbackground=theme.TEAL, font=theme.FONT_MONO, padx=10, pady=9)
text.pack(fill="both", expand=True, padx=11, pady=(4, 11))
content = "\n".join(list(lines)[:260]) or "暂无数据"
text.insert("1.0", content)
text.configure(state="disabled")
@@ -67,47 +279,99 @@ def table_panel(parent, title: str, columns: Sequence[tuple[str, str, int]], row
tree.column(key, width=width, anchor="w")
for row in rows:
tree.insert("", "end", values=[str(row.get(key, "-")) for key, _, _ in columns])
tree.pack(fill="both", expand=True, padx=12, pady=(4, 12))
if not rows:
tree.insert("", "end", values=["暂无数据" if idx == 0 else "" for idx, _c in enumerate(columns)])
tree.pack(fill="both", expand=True, padx=11, pady=(4, 11))
return box
def field(parent, label: str, value: object, *, wide: bool = False) -> tk.Frame:
row = tk.Frame(parent, bg=theme.SURFACE)
ttk.Label(row, text=label, style="Small.TLabel", width=18).pack(side="left")
ent = ttk.Entry(row)
ent.insert(0, str(value))
ent.pack(side="left", fill="x", expand=True)
if not wide:
ent.configure(width=18)
return row
def switch_row(parent, label: str, value: bool) -> tk.Frame:
row = tk.Frame(parent, bg=theme.SURFACE)
var = tk.BooleanVar(value=bool(value))
ttk.Checkbutton(row, text=label, variable=var).pack(side="left")
return row
def preview_panel(parent, image_path: Path | None, title: str = "截图预览") -> tk.Frame:
def mini_table(parent, title: str, rows: Sequence[tuple[str, str, str]], *, color: str = theme.TEAL) -> tk.Frame:
box = card(parent, title)
body = tk.Frame(box, bg="#fbfcfa", highlightbackground=theme.BORDER, highlightthickness=1)
body.pack(fill="both", expand=True, padx=12, pady=(4, 12))
body = tk.Frame(box, bg=theme.SURFACE)
body.pack(fill="both", expand=True, padx=11, pady=(4, 11))
if not rows:
tk.Label(body, text="暂无数据", bg=theme.SURFACE, fg=theme.MUTED, pady=20).pack(fill="x")
return box
for idx, (a, b, c) in enumerate(rows[:8]):
row = tk.Frame(body, bg=theme.SURFACE if idx % 2 == 0 else theme.SURFACE_ALT)
row.pack(fill="x", pady=1)
tk.Label(row, text=a, bg=row["bg"], fg=theme.TEXT, font=theme.FONT_SMALL, anchor="w").pack(side="left", fill="x", expand=True, padx=8, pady=5)
tk.Label(row, text=b, bg=row["bg"], fg=color, font=("Microsoft YaHei UI", 9, "bold"), width=10).pack(side="left", padx=4)
tk.Label(row, text=c, bg=row["bg"], fg=theme.MUTED, font=theme.FONT_SMALL, width=12).pack(side="left", padx=4)
return box
def field(parent, label: str, variable: tk.Variable | None = None, *, value: object = "", wide: bool = False) -> tk.Frame:
row = tk.Frame(parent, bg=theme.SURFACE_ALT, highlightbackground=theme.BORDER, highlightthickness=1)
tk.Label(row, text=label, bg=theme.SURFACE_ALT, fg=theme.MUTED, font=theme.FONT_SMALL).pack(anchor="w", padx=9, pady=(7, 1))
if variable is None:
variable = tk.StringVar(value=str(value))
entry = tk.Entry(
row,
textvariable=variable,
bg=theme.SURFACE_ALT,
fg=theme.TEXT,
insertbackground=theme.TEAL,
relief="flat",
bd=0,
font=theme.FONT_UI,
)
entry.pack(fill="x", padx=9, pady=(0, 8))
return row
def switch_row(parent, label: str, variable: tk.Variable | None = None, value: bool = False) -> tk.Frame:
row = tk.Frame(parent, bg=theme.SURFACE_ALT, highlightbackground=theme.BORDER, highlightthickness=1)
var = variable if variable is not None else tk.BooleanVar(value=bool(value))
tk.Checkbutton(
row,
text=label,
variable=var,
bg=theme.SURFACE_ALT,
fg=theme.TEXT,
activebackground=theme.SURFACE_ALT,
activeforeground=theme.TEXT,
selectcolor=theme.SURFACE,
relief="flat",
bd=0,
anchor="w",
justify="left",
font=theme.FONT_SMALL,
).pack(fill="x", padx=9, pady=6)
return row
def toolbar(parent, actions: Sequence[tuple[str, Callable[[], None] | None, str]] | Sequence[str]) -> tk.Frame:
row = tk.Frame(parent, bg=theme.BG)
row.pack(fill="x", pady=(0, 8))
for item in actions:
if isinstance(item, str):
text, command, kind = item, None, "soft"
else:
text, command, kind = item
button(row, text, command, kind=kind).pack(side="left", padx=(0, 6))
return row
def preview_panel(parent, image_path: Path | None, title: str = "截图预览", max_size: tuple[int, int] = (360, 560)) -> tk.Frame:
box = card(parent, title)
body = tk.Frame(box, bg=theme.SURFACE_ALT, highlightbackground=theme.BORDER, highlightthickness=1)
body.pack(fill="both", expand=True, padx=11, pady=(4, 11))
if image_path and image_path.exists():
try:
from PIL import Image, ImageTk
img = Image.open(image_path).convert("RGB")
img.thumbnail((320, 520))
img.thumbnail(max_size)
photo = ImageTk.PhotoImage(img)
label = tk.Label(body, image=photo, bg="#fbfcfa")
label = tk.Label(body, image=photo, bg=theme.SURFACE_ALT)
label.image = photo
label.pack(expand=True, pady=10)
ttk.Label(body, text=os.path.basename(str(image_path)), background="#fbfcfa", foreground=theme.MUTED).pack(pady=(0, 8))
ttk.Label(body, text=os.path.basename(str(image_path)), background=theme.SURFACE_ALT, foreground=theme.MUTED).pack(pady=(0, 8))
return box
except Exception:
pass
tk.Label(body, text="暂无截图\n点击“截图+OCR”后刷新", bg="#fbfcfa", fg=theme.MUTED, font=("Microsoft YaHei UI", 14)).pack(expand=True)
tk.Label(body, text="暂无截图\n点击“截图+OCR”后刷新", bg=theme.SURFACE_ALT, fg=theme.MUTED, font=("Microsoft YaHei UI", 13)).pack(expand=True)
return box
@@ -130,4 +394,3 @@ class ScrollFrame(ttk.Frame):
self.canvas.yview_scroll(int(-1 * (event.delta / 120)), "units")
except Exception:
pass
+15
View File
@@ -0,0 +1,15 @@
$ErrorActionPreference = "Stop"
$Root = Resolve-Path (Join-Path $PSScriptRoot "..\..")
Set-Location $Root
$Stamp = Get-Date -Format "yyyyMMdd_HHmmss"
$OutDir = Join-Path $Root "artifacts\gui_dashboard_ui_review_$Stamp"
$Index = python tools\gui\export_dashboard_ui_review.py --out $OutDir
if ($LASTEXITCODE -ne 0) {
throw "UI review export failed"
}
Write-Host "UI review exported:" $Index
Start-Process $Index
+112
View File
@@ -0,0 +1,112 @@
from __future__ import annotations
import argparse
import ctypes
import html
import sys
import time
from pathlib import Path
from PIL import ImageGrab
ROOT = Path(__file__).resolve().parents[2]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
try:
ctypes.windll.user32.SetProcessDPIAware()
except Exception:
pass
from gui.dashboard_app.app import DashboardApp
from gui.dashboard_app.page_registry import PAGES
def _slug(name: str) -> str:
safe = "".join(ch for ch in name if ch not in '\\/:*?"<>|').strip()
return safe or "page"
def _capture_window(app: DashboardApp, out: Path) -> None:
try:
app.root.attributes("-topmost", True)
app.root.lift()
app.root.focus_force()
except Exception:
pass
app.root.update_idletasks()
app.root.update()
time.sleep(0.2)
app.root.update()
x = app.root.winfo_rootx()
y = app.root.winfo_rooty()
w = app.root.winfo_width()
h = app.root.winfo_height()
ImageGrab.grab(bbox=(x, y, x + w, y + h)).save(out)
try:
app.root.attributes("-topmost", False)
except Exception:
pass
def export(out_dir: Path) -> Path:
out_dir.mkdir(parents=True, exist_ok=True)
app = DashboardApp()
app.root.geometry("1280x860+80+60")
app.root.update()
shots = []
try:
for idx, name in enumerate(PAGES, 1):
app.show_page(name)
app.root.lift()
app.root.update()
filename = f"{idx:02d}-{_slug(name)}.png"
path = out_dir / filename
_capture_window(app, path)
shots.append((name, filename))
finally:
app.root.destroy()
index = out_dir / "index.html"
cards = "\n".join(
f'<section><h2>{html.escape(name)}</h2><a href="{html.escape(filename)}"><img src="{html.escape(filename)}" alt="{html.escape(name)}"></a></section>'
for name, filename in shots
)
index.write_text(
f"""<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>gui_app 新 UI 核对包</title>
<style>
body {{ margin: 0; padding: 28px; background: #f5f7f4; color: #172322; font-family: "Microsoft YaHei UI", sans-serif; }}
h1 {{ margin: 0 0 8px; font-size: 24px; }}
p {{ margin: 0 0 24px; color: #6f7f7d; }}
main {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 18px; }}
section {{ background: white; border: 1px solid #dbe5df; padding: 14px; }}
h2 {{ margin: 0 0 10px; font-size: 15px; }}
img {{ display: block; width: 100%; height: auto; border: 1px solid #dbe5df; }}
</style>
</head>
<body>
<h1>gui_app 新 UI 核对包</h1>
<p>共导出 {len(shots)} 个界面,点击图片可看原尺寸。</p>
<main>{cards}</main>
</body>
</html>
""",
encoding="utf-8",
)
return index
def main() -> None:
parser = argparse.ArgumentParser(description="导出 gui_app 新 UI 的全页面截图核对包")
parser.add_argument("--out", default="artifacts/gui_dashboard_ui_review", help="输出目录")
args = parser.parse_args()
index = export(Path(args.out).resolve())
print(index)
if __name__ == "__main__":
main()