improve dashboard nav scroll and reservation details

This commit is contained in:
Your Name committed 2026-06-19 20:24:59 +08:00
1 parent 0f1baac92f
commit 4891f3b019
5 files changed
+53 -11

No files matched your search

+14 -3
View File
@@ -111,11 +111,21 @@ class DashboardApp:
nav_canvas.bind("<Configure>", lambda e: nav_canvas.itemconfigure(nav_window, width=e.width))
def _nav_wheel(event):
nav_canvas.yview_scroll(int(-1 * (event.delta / 120)), "units")
delta = getattr(event, "delta", 0)
if delta:
units = -1 if delta > 0 else 1
else:
units = -1 if getattr(event, "num", 0) == 4 else 1
nav_canvas.yview_scroll(units * 3, "units")
return "break"
nav_canvas.bind("<MouseWheel>", _nav_wheel)
nav_inner.bind("<MouseWheel>", _nav_wheel)
def _bind_nav_wheel(widget: tk.Widget) -> None:
widget.bind("<MouseWheel>", _nav_wheel, add="+")
widget.bind("<Button-4>", _nav_wheel, add="+")
widget.bind("<Button-5>", _nav_wheel, add="+")
for child in widget.winfo_children():
_bind_nav_wheel(child)
for group_title, names in [
("总览", ["数据看板"]),
("配置", ["运行设置", "筛选设置", "高价值预约", "养号设置", "调试参数", "授权", "日志配置", "关键词"]),
@@ -127,6 +137,7 @@ class DashboardApp:
btn = nav_button(nav_inner, name, lambda n=name: self.show_page(n), active=name == self.current_page)
btn.pack(fill="x", padx=10, pady=1)
self.nav_buttons[name] = btn
_bind_nav_wheel(sidebar)
self.content_scroll = ScrollFrame(main)
self.content_scroll.grid(row=0, column=1, sticky="nsew")
+2
View File
@@ -15,6 +15,7 @@ class DashboardData:
cfg: dict[str, Any]
run_log: list[str]
action_log: list[str]
reservations_state: dict[str, Any]
reservations: list[dict[str, Any]]
high_value_rooms: list[dict[str, Any]]
mapping_rows: list[dict[str, Any]]
@@ -176,6 +177,7 @@ def load_dashboard_data() -> DashboardData:
cfg=cfg if isinstance(cfg, dict) else {},
run_log=_tail(path_config.get_log_file_path(), 240) or _tail(path_config.get_simple_log_path(), 240),
action_log=_tail(path_config.get_actions_log_path(), 240),
reservations_state=reservations_raw if isinstance(reservations_raw, dict) else {},
reservations=_normalize_rows(reservations_raw, ("reservations", "items", "queue")),
high_value_rooms=_normalize_rows(high_raw, ("rooms", "items", "records")),
mapping_rows=_mapping_rows(),
+6 -3
View File
@@ -183,10 +183,13 @@ def build_reservation_queue(parent: tk.Misc, data: DashboardData, ctx: PageConte
toolbar(parent, [("刷新", ctx.action("refresh"), "soft")])
rows = reservation_rows(data)
for row in rows:
row["time"] = fmt_ts(row["time"])
row["target_time"] = fmt_ts(row["target_time"])
row["created_time"] = fmt_ts(row["created_time"])
table_panel(parent, "预约队列", (
("idx", "#", 40), ("title", "直播间", 190), ("content", "内容", 250),
("value", "价值", 80), ("status", "状态", 90), ("time", "时间", 170),
("idx", "#", 40), ("pos", "位置", 70), ("title", "直播间", 220), ("raw_title", "原始标题", 240),
("content", "内容", 220), ("value", "价值", 80), ("countdown", "倒计时/开奖", 120),
("participants", "人数", 74), ("copies", "份数", 70), ("task_count", "任务数", 74),
("status", "状态", 90), ("target_time", "开奖时间", 160), ("created_time", "记录时间", 160),
), rows, height=18).pack(fill="both", expand=True)
+28 -2
View File
@@ -117,13 +117,39 @@ def text_box(
def reservation_rows(data) -> list[dict]:
rows = []
for idx, item in enumerate(data.reservations[:24], 1):
for idx, item in enumerate(data.reservations, 1):
rows.append({
"idx": idx,
"pos": item.get("pos_seen") or item.get("room_pos") or item.get("pos") or "-",
"title": item.get("room_title") or item.get("title") or item.get("live_title") or "-",
"raw_title": item.get("room_title_raw") or item.get("title_raw") 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 "-",
"countdown": item.get("time_text") or item.get("countdown") or item.get("future_str") or "-",
"participants": item.get("participants") or "-",
"copies": item.get("copies") or "-",
"task_count": item.get("task_count") 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 "-",
"target_time": item.get("future_ts") or item.get("target_ts") or "-",
"created_time": item.get("created_ts") or "-",
})
if rows:
return rows
state = getattr(data, "reservations_state", {}) or {}
if isinstance(state, dict) and state:
rows.append({
"idx": "-",
"pos": state.get("room_pos") or "-",
"title": state.get("current_room_title") or "-",
"raw_title": state.get("current_room_title_raw") or "-",
"content": state.get("reason") or "队列为空",
"value": "-",
"countdown": "-",
"participants": "-",
"copies": "-",
"task_count": "-",
"status": "队列为空",
"target_time": "-",
"created_time": state.get("updated_ts") or "-",
})
return rows
+3 -3
View File
@@ -93,10 +93,10 @@ def build_home(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None:
rows = reservation_rows(data)
for row in rows:
row["time"] = fmt_ts(row["time"])
row["target_time"] = fmt_ts(row["target_time"])
table_panel(left, "预约队列", (
("idx", "#", 32), ("title", "直播间", 108), ("content", "内容", 168),
("value", "价值", 54), ("status", "状态", 58), ("time", "时间", 92),
("idx", "#", 32), ("pos", "位置", 54), ("title", "直播间", 120), ("content", "内容", 160),
("value", "价值", 58), ("countdown", "倒计时", 76), ("status", "状态", 68), ("target_time", "开奖时间", 132),
), rows, height=18).pack(fill="both", expand=True)
preview_panel(right, data.current_screenshot_path, "实时截图").pack(fill="both", expand=True)