feat: 更新配置文件以启用调试捕获,调整福袋相关坐标,优化预约处理逻辑,增强界面显示信息

This commit is contained in:
Your Name committed 2026-01-16 03:04:11 +08:00
1 parent 362b7c841c
commit df65adfe4e
19 files changed
+127 -1994

No files matched your search

+82 -14
View File
@@ -2686,7 +2686,7 @@ def main():
map_ctrl = ttk.Frame(map_box)
map_ctrl.pack(fill=X, padx=10, pady=(8, 6))
map_auto_refresh_var = tk.BooleanVar(value=False)
map_auto_refresh_var = tk.BooleanVar(value=True)
ttk.Checkbutton(
map_ctrl, text="自动刷新(5s)", variable=map_auto_refresh_var
).pack(side=LEFT)
@@ -2697,14 +2697,28 @@ def main():
ttk.Label(map_ctrl, textvariable=mapping_source_var).pack(side=LEFT, padx=(8, 0))
mapping_tree = ttk.Treeview(
mapping_tab, columns=("pos", "title", "title_raw"), show="headings", height=12
mapping_tab, columns=("pos", "title", "title_raw", "has_fudai", "fudai_content", "fudai_time", "fudai_value", "participants", "copies", "is_reserved"), show="headings", height=12
)
mapping_tree.heading("pos", text="位置")
mapping_tree.heading("title", text="标题")
mapping_tree.heading("title_raw", text="原始标题")
mapping_tree.column("pos", width=80, anchor="e")
mapping_tree.column("title", width=340, anchor="w")
mapping_tree.column("title_raw", width=340, anchor="w")
mapping_tree.heading("has_fudai", text="有福袋")
mapping_tree.heading("fudai_content", text="福袋内容")
mapping_tree.heading("fudai_time", text="开奖时间")
mapping_tree.heading("fudai_value", text="价值(元)")
mapping_tree.heading("participants", text="参与人数")
mapping_tree.heading("copies", text="份数")
mapping_tree.heading("is_reserved", text="已预约")
mapping_tree.column("pos", width=50, anchor="e")
mapping_tree.column("title", width=150, anchor="w")
mapping_tree.column("title_raw", width=150, anchor="w")
mapping_tree.column("has_fudai", width=60, anchor="center")
mapping_tree.column("fudai_content", width=150, anchor="w")
mapping_tree.column("fudai_time", width=120, anchor="center")
mapping_tree.column("fudai_value", width=80, anchor="e")
mapping_tree.column("participants", width=80, anchor="e")
mapping_tree.column("copies", width=60, anchor="e")
mapping_tree.column("is_reserved", width=60, anchor="center")
mapping_tree.pack(fill=BOTH, expand=True, padx=10, pady=(6, 10))
# 加载映射表到表格(尝试多个可能的路径)
@@ -2715,6 +2729,33 @@ def main():
except Exception:
pass
# 加载预约状态(用于检查是否已预约)
reservations_data = {}
try:
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
reservations_paths = [
os.path.join(base_dir, "douyin", "core", "state", "reservations.json"),
os.path.join(base_dir, "douyin", "state", "reservations.json"),
os.path.join(os.getcwd(), "douyin", "core", "state", "reservations.json"),
]
for res_path in reservations_paths:
try:
if os.path.exists(res_path):
with open(res_path, "r", encoding="utf-8") as f:
res_raw = f.read()
res_parsed = json.loads(res_raw)
if isinstance(res_parsed, dict) and "queue" in res_parsed:
# 提取预约队列中的位置信息
for item in res_parsed["queue"]:
pos = item.get("pos_seen", 0)
if pos:
reservations_data[pos] = item
break
except Exception:
pass
except Exception:
pass
# 优先使用基于项目目录的固定路径,避免不同工作目录导致无法找到状态文件
try:
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
@@ -2743,7 +2784,7 @@ def main():
if not parsed:
# 非JSON或解析错误:在表格中显示原始文本的一行提示
mapping_tree.insert(
"", "end", values=("-", "(非JSON,查看原始文件)", "")
"", "end", values=("-", "(非JSON,查看原始文件)", "", "", "", "", "", "", "", "")
)
else:
# 移除元信息
@@ -2763,18 +2804,45 @@ def main():
if isinstance(v, dict):
# 新格式:字典
title = (v.get("title", "") or "").strip() or "-"
title_raw = (v.get("title_raw", "") or "").strip() or "-"
has_fudai = v.get("has_fudai", False)
fudai_content = (v.get("fudai_content", "") or "").strip()
if has_fudai and fudai_content:
title += f" [福袋:{fudai_content[:20]}]"
title_raw = (
v.get("title_raw", "") or ""
).strip() or "-"
has_fudai = "✓" if v.get("has_fudai", False) else ""
fudai_content = (
v.get("fudai_content", "") or ""
).strip() or "-"
# 提取福袋详细信息
fudai_detail = v.get("fudai_detail")
if fudai_detail and isinstance(fudai_detail, (tuple, list)) and len(fudai_detail) >= 5:
# fudai_detail结构: (content, time_text, participants, copies, prize_value_yuan, countdown_tuple)
fudai_time = fudai_detail[1] or "-" # time_text
fudai_value = f"{fudai_detail[4] or 0:.2f}" if fudai_detail[4] else "-" # prize_value_yuan
participants = str(fudai_detail[2] or 0) if fudai_detail[2] else "-" # participants
copies = str(fudai_detail[3] or 0) if fudai_detail[3] else "-" # copies
else:
fudai_time = "-"
fudai_value = "-"
participants = "-"
copies = "-"
# 检查是否已预约
is_reserved = "✓" if int(k) in reservations_data else ""
else:
# 兼容旧格式:元组
title = (v[0] or "").strip() or "-"
title_raw = (v[1] or "").strip() or "-"
has_fudai = ""
fudai_content = "-"
fudai_time = "-"
fudai_value = "-"
participants = "-"
copies = "-"
is_reserved = "✓" if int(k) in reservations_data else ""
except Exception:
title, title_raw = "-", "-"
mapping_tree.insert("", "end", values=(k, title, title_raw))
title, title_raw, has_fudai, fudai_content, fudai_time, fudai_value, participants, copies, is_reserved = "-", "-", "", "-", "-", "-", "-", "-", "-"
mapping_tree.insert("", "end", values=(k, title, title_raw, has_fudai, fudai_content, fudai_time, fudai_value, participants, copies, is_reserved))
found = True
break
@@ -2784,7 +2852,7 @@ def main():
if not found:
mapping_source_var.set("未找到 room_pos_map.json")
mapping_tree.insert("", "end", values=("-", "未找到映射表文件", ""))
mapping_tree.insert("", "end", values=("-", "未找到映射表文件", "", "", "", "", "", "", "", ""))
# 绑定刷新按钮与自动刷新
btns = map_ctrl.winfo_children()