Show live action status on dashboard

This commit is contained in:
Your Name committed 2026-06-18 17:15:57 +08:00
1 parent 00821d0926
commit a25336770f
1 file changed
+28 -1
+28 -1
View File
@@ -9,10 +9,37 @@ from .page_helpers import reservation_rows
from .widgets import flow_grid, section, stat_tile, table_panel, text_panel
def _current_action_status(data: DashboardData, fallback: str = "暂无动作") -> str:
for raw_line in reversed(data.action_log):
line = str(raw_line).strip()
if not line or set(line) == {"="}:
continue
if "识别" in line:
return "识别中"
if "点击" in line or "参与" in line:
return "点击参与"
if "等待" in line or "开奖" in line:
return "等待开奖"
if "上滑" in line or "切换直播间" in line:
return "切换直播间"
if "预约" in line:
return "记录预约"
if "程序运行结束" in line:
return "已结束"
if "程序开始运行" in line:
return "运行中"
marker = " - [ACTION] "
if marker in line:
action = line.split(marker, 1)[1].split("耗时=", 1)[0].strip()
return action[:12] or fallback
return fallback
def build_home(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
section(parent, "数据看板", "运行状态 / 队列 / 动作")
metrics = flow_grid(parent, 2)
status_text = ctx.status_var.get() if ctx.status_var is not None else "就绪"
fallback_status = ctx.status_var.get() if ctx.status_var is not None else "暂无动作"
status_text = _current_action_status(data, fallback_status or "暂无动作")
values = [
("中奖截图", len(data.win_images), "pic/lottery", theme.RED, theme.RED_SOFT),
("当前状态", status_text or "就绪", "运行状态", theme.TEAL, theme.TEAL_SOFT),