From 9744b758785672b4897f762371df24d8d1148366 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 30 May 2026 17:14:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor(gui):=20=E6=8A=BD=20127=20=E4=B8=AA=20?= =?UTF-8?q?Var=20=E5=A3=B0=E6=98=8E=E5=88=B0=20components/config=5Fvars=20?= =?UTF-8?q?=E5=B7=A5=E5=8E=82=20(1373=20=E2=86=92=201110)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui/components/config_vars.py | 538 ++++++++++++++++++++++++++++++++++ gui/gui_app.py | 525 +++++++++------------------------ 2 files changed, 669 insertions(+), 394 deletions(-) create mode 100644 gui/components/config_vars.py diff --git a/gui/components/config_vars.py b/gui/components/config_vars.py new file mode 100644 index 0000000..4ec8669 --- /dev/null +++ b/gui/components/config_vars.py @@ -0,0 +1,538 @@ +"""GUI Var 工厂:从 ``cfg`` 构建所有 ``tkinter`` Var 实例。 + +从 ``gui/gui_app.py`` 抽出 127 个 Var 声明。返回名→Var 的 dict,``main()`` 在解构后 +继续以原变量名使用(避免改动 134 处现有引用点)。 +""" + +from __future__ import annotations + +import tkinter as tk +from typing import Dict + + +def build_config_vars(cfg: dict) -> Dict[str, tk.Variable]: + """从 cfg 构建所有 tk Var 实例,返回名→Var 字典。""" + y_var = tk.IntVar(value=int(cfg.get("y_pianyi", 0) or 0)) + enable_back_on_misses_var = tk.BooleanVar( + value=bool(cfg.get("enable_back_on_misses", True)) + ) + swipe_down_back_enabled_var = tk.BooleanVar( + value=bool(cfg.get("swipe_down_back_enabled", False)) + ) + swipe_down_back_count_var = tk.IntVar( + value=int(cfg.get("swipe_down_back_count", 3) or 3) + ) + needswitch_var = tk.BooleanVar(value=bool(cfg.get("needswitch", True))) + infinite_loop_var = tk.BooleanVar( + value=bool(cfg.get("infinite_loop_enabled", False)) + ) + wait_minutes_var = tk.IntVar(value=int(cfg.get("wait_minutes", 5) or 5)) + min_value_var = tk.DoubleVar(value=float(cfg.get("min_prize_value_yuan", 0) or 0)) + min_participants_var = tk.IntVar(value=int(cfg.get("min_participants", 0) or 0)) + max_participants_var = tk.IntVar(value=int(cfg.get("max_participants", 0) or 0)) + skip_gt_seconds_var = tk.IntVar( + value=int(cfg.get("skip_if_countdown_gt_seconds", 900) or 900) + ) + reset_after_swipes_enabled_var = tk.BooleanVar( + value=bool(cfg.get("reset_after_swipes_enabled", False)) + ) + reset_after_swipes_var = tk.IntVar( + value=int(cfg.get("reset_after_swipes", 10) or 10) + ) + reset_after_swipes_action_var = tk.StringVar( + value=str(cfg.get("reset_after_swipes_action", "swipe") or "swipe") + ) + enable_back_on_misses_var = tk.BooleanVar( + value=bool(cfg.get("enable_back_on_misses", True)) + ) + streaming_enabled_var = tk.BooleanVar( + value=bool(cfg.get("enable_streaming_screenshot", True)) + ) + auto_join_var = tk.BooleanVar(value=bool(cfg.get("auto_join_fansclub", False))) + fansclub_action_var = tk.StringVar( + value=str(cfg.get("fansclub_fail_action", "stay") or "stay").lower() + ) + fansclub_click_delay_var = tk.DoubleVar( + value=float(cfg.get("fansclub_click_delay", 0.6) or 0.6) + ) + fansclub_auto_wait_var = tk.DoubleVar( + value=float(cfg.get("fansclub_auto_join_wait_seconds", 5.0) or 5.0) + ) + fansclub_manual_wait_var = tk.DoubleVar( + value=float(cfg.get("fansclub_manual_wait_seconds", 3.0) or 3.0) + ) + high_value_fudai_enabled_var = tk.BooleanVar( + value=bool(cfg.get("high_value_fudai_enabled", False)) + ) + high_value_fudai_threshold_yuan_var = tk.DoubleVar( + value=float(cfg.get("high_value_fudai_threshold_yuan", 1000) or 1000) + ) + high_value_fudai_join_ahead_seconds_var = tk.IntVar( + value=int(cfg.get("high_value_fudai_join_ahead_seconds", 300) or 300) + ) + high_value_fudai_max_swipe_back_var = tk.IntVar( + value=int(cfg.get("high_value_fudai_max_swipe_back", 60) or 60) + ) + high_value_fudai_max_reservations_var = tk.IntVar( + value=int(cfg.get("high_value_fudai_max_reservations", 5) or 5) + ) + high_value_fudai_after_action_var = tk.StringVar( + value=str(cfg.get("high_value_fudai_after_action", "continue") or "continue") + ) + high_value_fudai_poll_before_seconds_var = tk.DoubleVar( + value=float(cfg.get("high_value_fudai_poll_before_seconds", 10.0) or 10.0) + ) + high_value_room_revisit_enabled_var = tk.BooleanVar( + value=bool(cfg.get("high_value_room_revisit_enabled", True)) + ) + high_value_room_revisit_only_current_run_var = tk.BooleanVar( + value=bool(cfg.get("high_value_room_revisit_only_current_run", False)) + ) + high_value_room_revisit_min_interval_seconds_var = tk.IntVar( + value=int(cfg.get("high_value_room_revisit_min_interval_seconds", 300)) + ) + high_value_room_revisit_max_per_run_var = tk.IntVar( + value=int(cfg.get("high_value_room_revisit_max_per_run", 5)) + ) + high_value_room_revisit_min_prize_value_var = tk.DoubleVar( + value=float(cfg.get("high_value_room_revisit_min_prize_value", 0.0)) + ) + high_value_room_revisit_max_age_days_var = tk.IntVar( + value=int(cfg.get("high_value_room_revisit_max_age_days", 30)) + ) + reservation_back_verify_enabled_var = tk.BooleanVar( + value=bool(cfg.get("reservation_back_verify_enabled", True)) + ) + reservation_back_swipe_delay_var = tk.DoubleVar( + value=float(cfg.get("reservation_back_swipe_delay", 0) or 0) + ) + reservation_back_verify_wait_seconds_var = tk.DoubleVar( + value=float(cfg.get("reservation_back_verify_wait_seconds", 5.0) or 5.0) + ) + fudai_find_max_attempts_var = tk.IntVar( + value=int(cfg.get("fudai_find_max_attempts", 0) or 0) + ) + fudai_icon_retry_delay_seconds_var = tk.DoubleVar( + value=float(cfg.get("fudai_icon_retry_delay_seconds", 0.6) or 0.6) + ) + fudai_icon_max_wait_seconds_var = tk.DoubleVar( + value=float(cfg.get("fudai_icon_max_wait_seconds", 5.0) or 5.0) + ) + fudai_disable_content_recognition_var = tk.BooleanVar( + value=bool(cfg.get("fudai_disable_content_recognition", False)) + ) + fudai_disable_task_recognition_var = tk.BooleanVar( + value=bool(cfg.get("fudai_disable_task_recognition", False)) + ) + fudai_exit_after_misses_var = tk.IntVar( + value=int(cfg.get("fudai_exit_after_misses", 30) or 30) + ) + fudai_click_wait_seconds_var = tk.DoubleVar( + value=float(cfg.get("fudai_click_wait_seconds", 1.0) or 1.0) + ) + switch_room_wait_after_stage_diag_seconds_var = tk.DoubleVar( + value=float(cfg.get("switch_room_wait_after_stage_diag_seconds", 7.0) or 7.0) + ) + live_room_match_threshold_var = tk.DoubleVar( + value=float(cfg.get("live_room_match_threshold", 0.8) or 0.8) + ) + swipe_duration_ms_var = tk.IntVar( + value=int(cfg.get("swipe_duration_ms", 600) or 600) + ) + swipe_up_start_y_var = tk.IntVar( + value=int(cfg.get("swipe_up_start_y", 1200) or 1200) + ) + swipe_up_end_y_var = tk.IntVar(value=int(cfg.get("swipe_up_end_y", 600) or 600)) + yg_enabled_var = tk.BooleanVar(value=bool(cfg.get("yanghao_enabled", True))) + yg_actions_enabled_var = tk.BooleanVar( + value=bool(cfg.get("yanghao_enable_actions", True)) + ) + yg_only_var = tk.BooleanVar(value=bool(cfg.get("yanghao_only", False))) + yg_recommend_duration_var = tk.IntVar( + value=int(cfg.get("yanghao_recommend_duration_seconds", 60) or 60) + ) + yg_recommend_interval_var = tk.IntVar( + value=int(cfg.get("yanghao_recommend_interval_seconds", 0) or 0) + ) + yg_like_prob_var = tk.DoubleVar( + value=float(cfg.get("yanghao_like_prob", 0.0) or 0.0) + ) + yg_fav_prob_var = tk.DoubleVar(value=float(cfg.get("yanghao_fav_prob", 0.0) or 0.0)) + yg_comment_prob_var = tk.DoubleVar( + value=float(cfg.get("yanghao_comment_prob", 0.0) or 0.0) + ) + yg_dwell_on_action_min_var = tk.DoubleVar( + value=float(cfg.get("yanghao_dwell_on_action_min_seconds", 5) or 5) + ) + yg_dwell_on_action_max_var = tk.DoubleVar( + value=float(cfg.get("yanghao_dwell_on_action_max_seconds", 30) or 30) + ) + yg_icon_roi_size_var = tk.IntVar( + value=int(cfg.get("yanghao_icon_roi_size", 240) or 240) + ) + yg_icon_match_threshold_var = tk.DoubleVar( + value=float(cfg.get("yanghao_icon_match_threshold", 0.72) or 0.72) + ) + yg_step_screenshot_var = tk.BooleanVar( + value=bool(cfg.get("yanghao_step_screenshot", False)) + ) + yg_like_roi_offset_x_var = tk.IntVar( + value=int(cfg.get("yanghao_like_roi_offset_x", 0) or 0) + ) + yg_like_roi_offset_y_var = tk.IntVar( + value=int(cfg.get("yanghao_like_roi_offset_y", 0) or 0) + ) + yg_fav_roi_offset_x_var = tk.IntVar( + value=int(cfg.get("yanghao_fav_roi_offset_x", 0) or 0) + ) + yg_fav_roi_offset_y_var = tk.IntVar( + value=int(cfg.get("yanghao_fav_roi_offset_y", 0) or 0) + ) + yg_like_icon_x_var = tk.IntVar(value=int(cfg.get("yanghao_like_icon_x", 0) or 0)) + yg_like_icon_y_var = tk.IntVar(value=int(cfg.get("yanghao_like_icon_y", 0) or 0)) + yg_fav_icon_x_var = tk.IntVar(value=int(cfg.get("yanghao_fav_icon_x", 0) or 0)) + yg_fav_icon_y_var = tk.IntVar(value=int(cfg.get("yanghao_fav_icon_y", 0) or 0)) + yg_like_template_path_var = tk.StringVar( + value=str( + cfg.get("yanghao_like_template_path", "assets/like.png") + or "assets/like.png" + ) + ) + yg_fav_template_path_var = tk.StringVar( + value=str( + cfg.get("yanghao_fav_template_path", "assets/fav.png") or "assets/fav.png" + ) + ) + yg_like_icon_x_var = tk.IntVar(value=int(cfg.get("yanghao_like_icon_x", 0) or 0)) + yg_like_icon_y_var = tk.IntVar(value=int(cfg.get("yanghao_like_icon_y", 0) or 0)) + yg_fav_icon_x_var = tk.IntVar(value=int(cfg.get("yanghao_fav_icon_x", 0) or 0)) + yg_fav_icon_y_var = tk.IntVar(value=int(cfg.get("yanghao_fav_icon_y", 0) or 0)) + yg_after_dwell_direction_var = tk.StringVar( + value=str(cfg.get("yanghao_after_dwell_swipe_direction", "up") or "up") + ) + yg_after_dwell_distance_var = tk.IntVar( + value=int(cfg.get("yanghao_after_dwell_swipe_distance_px", 900) or 900) + ) + yg_comment_btn_x_var = tk.IntVar( + value=int(cfg.get("yanghao_comment_btn_x", 0) or 0) + ) + yg_comment_btn_y_var = tk.IntVar( + value=int(cfg.get("yanghao_comment_btn_y", 0) or 0) + ) + yg_comment_input_x_var = tk.IntVar( + value=int(cfg.get("yanghao_comment_input_x", 0) or 0) + ) + yg_comment_input_y_var = tk.IntVar( + value=int(cfg.get("yanghao_comment_input_y", 0) or 0) + ) + yg_comment_send_x_var = tk.IntVar( + value=int(cfg.get("yanghao_comment_send_x", 0) or 0) + ) + yg_comment_send_y_var = tk.IntVar( + value=int(cfg.get("yanghao_comment_send_y", 0) or 0) + ) + yg_comment_close_x_var = tk.IntVar( + value=int(cfg.get("yanghao_comment_close_x", 0) or 0) + ) + yg_comment_close_y_var = tk.IntVar( + value=int(cfg.get("yanghao_comment_close_y", 0) or 0) + ) + fudai_quiet_hours_enabled_var = tk.BooleanVar( + value=bool(cfg.get("fudai_quiet_hours_enabled", True)) + ) + fudai_quiet_start_hour_var = tk.IntVar( + value=int(cfg.get("fudai_quiet_start_hour", 2) or 2) + ) + fudai_quiet_end_hour_var = tk.IntVar( + value=int(cfg.get("fudai_quiet_end_hour", 7) or 7) + ) + stage_diag_max_time_var = tk.DoubleVar( + value=float(cfg.get("stage_diag_max_time", 10.0) or 10.0) + ) + stage_diag_max_step_time_var = tk.DoubleVar( + value=float(cfg.get("stage_diag_max_step_time", 2.0) or 2.0) + ) + stage_diag_verbose_var = tk.BooleanVar( + value=bool(cfg.get("logging", {}).get("stage_diag_verbose", True)) + ) + enable_ocr_mode1_var = tk.BooleanVar(value=bool(cfg.get("enable_ocr_mode1", False))) + fudai_template_match_enabled_var = tk.BooleanVar( + value=bool(cfg.get("fudai_template_match_enabled", False)) + ) + fudai_template_match_threshold_var = tk.DoubleVar( + value=float(cfg.get("fudai_template_match_threshold", 0.7) or 0.7) + ) + fudai_detail_template_threshold_var = tk.DoubleVar( + value=float(cfg.get("fudai_detail_template_threshold", 0.7) or 0.7) + ) + lucky_draw_red_ratio_threshold_var = tk.DoubleVar( + value=float(cfg.get("lucky_draw_red_ratio_threshold", 0.9) or 0.9) + ) + coupon_template_match_threshold_var = tk.DoubleVar( + value=float(cfg.get("coupon_template_match_threshold", 0.75) or 0.75) + ) + attend_button_red_ratio_threshold_var = tk.DoubleVar( + value=float(cfg.get("attend_button_red_ratio_threshold", 0.25) or 0.25) + ) + fansclub_join_red_ratio_threshold_var = tk.DoubleVar( + value=float(cfg.get("fansclub_join_red_ratio_threshold", 0.25) or 0.25) + ) + shopping_redpacket_red_ratio_threshold_var = tk.DoubleVar( + value=float(cfg.get("shopping_redpacket_red_ratio_threshold", 0.15) or 0.15) + ) + debug_captures_enabled_var = tk.BooleanVar( + value=bool( + cfg.get("debug_captures", {}).get("enabled", False) + if isinstance(cfg.get("debug_captures"), dict) + else False + ) + ) + debug_captures_auto_cleanup_var = tk.BooleanVar( + value=bool( + cfg.get("debug_captures", {}).get("auto_cleanup", True) + if isinstance(cfg.get("debug_captures"), dict) + else True + ) + ) + debug_captures_keep_days_var = tk.IntVar( + value=int( + cfg.get("debug_captures", {}).get("keep_days", 7) + if isinstance(cfg.get("debug_captures"), dict) + else 7 + ) + ) + debug_captures_max_files_var = tk.IntVar( + value=int( + cfg.get("debug_captures", {}).get("max_files", 2000) + if isinstance(cfg.get("debug_captures"), dict) + else 2000 + ) + ) + debug_captures_async_save_var = tk.BooleanVar( + value=bool( + cfg.get("debug_captures", {}).get("async_save", True) + if isinstance(cfg.get("debug_captures"), dict) + else True + ) + ) + debug_captures_log_on_complete_var = tk.BooleanVar( + value=bool( + cfg.get("debug_captures", {}).get("log_on_complete", False) + if isinstance(cfg.get("debug_captures"), dict) + else False + ) + ) + debug_async_success_var = tk.IntVar(value=0) + debug_async_failure_var = tk.IntVar(value=0) + logging_beautify_var = tk.BooleanVar( + value=bool(cfg.get("logging", {}).get("beautify_output", True)) + ) + logging_color_var = tk.BooleanVar( + value=bool(cfg.get("logging", {}).get("color_output", True)) + ) + logging_show_timestamps_var = tk.BooleanVar( + value=bool(cfg.get("logging", {}).get("show_timestamps", True)) + ) + logging_use_dated_logs_var = tk.BooleanVar( + value=bool(cfg.get("logging", {}).get("use_dated_logs", True)) + ) + logging_enable_monitor_var = tk.BooleanVar( + value=bool(cfg.get("logging", {}).get("enable_monitor", True)) + ) + log_unified_enabled_var = tk.BooleanVar( + value=bool(cfg.get("log_unified_enabled", True)) + ) + log_unified_path_var = tk.StringVar( + value=str(cfg.get("log_unified_path", "logs/unified.log") or "logs/unified.log") + ) + logging_keep_days_var = tk.IntVar( + value=int(cfg.get("logging", {}).get("keep_days", 30) or 30) + ) + logging_compress_logs_var = tk.BooleanVar( + value=bool(cfg.get("logging", {}).get("compress_logs", True)) + ) + logging_max_total_size_gb_var = tk.DoubleVar( + value=float(cfg.get("logging", {}).get("max_total_size_gb", 10.0) or 10.0) + ) + logging_compress_after_days_var = tk.IntVar( + value=int(cfg.get("logging", {}).get("compress_after_days", 7) or 7) + ) + logging_performance_enabled_var = tk.BooleanVar( + value=bool( + cfg.get("logging", {}).get("performance_tracking", {}).get("enabled", True) + ) + ) + logging_track_functions_var = tk.BooleanVar( + value=bool( + cfg.get("logging", {}) + .get("performance_tracking", {}) + .get("track_function_calls", True) + ) + ) + logging_debug_level_var = tk.StringVar( + value=str(cfg.get("logging", {}).get("debug_detail_level", "normal")) + ) + logging_error_level_var = tk.StringVar( + value=str(cfg.get("logging", {}).get("error_detail_level", "full")) + ) + logging_action_format_var = tk.StringVar( + value=str(cfg.get("logging", {}).get("action_log_format", "concise")) + ) + logging_format_mode_var = tk.StringVar( + value=str(cfg.get("logging", {}).get("log_format_mode", "simple")) + ) + logging_monitor_warning_mb_var = tk.DoubleVar( + value=float(cfg.get("logging", {}).get("monitor_warning_mb", 500.0) or 500.0) + ) + logging_monitor_critical_mb_var = tk.DoubleVar( + value=float(cfg.get("logging", {}).get("monitor_critical_mb", 2000.0) or 2000.0) + ) + gui_theme_var = tk.StringVar( + value=str(cfg.get("gui", {}).get("theme", "litera") or "litera") + ) + gui_realtime_refresh_interval_ms_var = tk.IntVar( + value=int( + cfg.get("gui", {}) + .get("realtime_status", {}) + .get("refresh_interval_ms", 1000) + or 1000 + ) + ) + gui_realtime_tail_items_var = tk.IntVar( + value=int( + cfg.get("gui", {}).get("realtime_status", {}).get("tail_items", 50) or 50 + ) + ) + skip_lt_seconds_var = tk.IntVar( + value=int(cfg.get("skip_if_countdown_lt_seconds", 10) or 10) + ) + + return { + "y_var": y_var, + "enable_back_on_misses_var": enable_back_on_misses_var, + "swipe_down_back_enabled_var": swipe_down_back_enabled_var, + "swipe_down_back_count_var": swipe_down_back_count_var, + "needswitch_var": needswitch_var, + "infinite_loop_var": infinite_loop_var, + "wait_minutes_var": wait_minutes_var, + "min_value_var": min_value_var, + "min_participants_var": min_participants_var, + "max_participants_var": max_participants_var, + "skip_gt_seconds_var": skip_gt_seconds_var, + "reset_after_swipes_enabled_var": reset_after_swipes_enabled_var, + "reset_after_swipes_var": reset_after_swipes_var, + "reset_after_swipes_action_var": reset_after_swipes_action_var, + "streaming_enabled_var": streaming_enabled_var, + "auto_join_var": auto_join_var, + "fansclub_action_var": fansclub_action_var, + "fansclub_click_delay_var": fansclub_click_delay_var, + "fansclub_auto_wait_var": fansclub_auto_wait_var, + "fansclub_manual_wait_var": fansclub_manual_wait_var, + "high_value_fudai_enabled_var": high_value_fudai_enabled_var, + "high_value_fudai_threshold_yuan_var": high_value_fudai_threshold_yuan_var, + "high_value_fudai_join_ahead_seconds_var": high_value_fudai_join_ahead_seconds_var, + "high_value_fudai_max_swipe_back_var": high_value_fudai_max_swipe_back_var, + "high_value_fudai_max_reservations_var": high_value_fudai_max_reservations_var, + "high_value_fudai_after_action_var": high_value_fudai_after_action_var, + "high_value_fudai_poll_before_seconds_var": high_value_fudai_poll_before_seconds_var, + "high_value_room_revisit_enabled_var": high_value_room_revisit_enabled_var, + "high_value_room_revisit_only_current_run_var": high_value_room_revisit_only_current_run_var, + "high_value_room_revisit_min_interval_seconds_var": high_value_room_revisit_min_interval_seconds_var, + "high_value_room_revisit_max_per_run_var": high_value_room_revisit_max_per_run_var, + "high_value_room_revisit_min_prize_value_var": high_value_room_revisit_min_prize_value_var, + "high_value_room_revisit_max_age_days_var": high_value_room_revisit_max_age_days_var, + "reservation_back_verify_enabled_var": reservation_back_verify_enabled_var, + "reservation_back_swipe_delay_var": reservation_back_swipe_delay_var, + "reservation_back_verify_wait_seconds_var": reservation_back_verify_wait_seconds_var, + "fudai_find_max_attempts_var": fudai_find_max_attempts_var, + "fudai_icon_retry_delay_seconds_var": fudai_icon_retry_delay_seconds_var, + "fudai_icon_max_wait_seconds_var": fudai_icon_max_wait_seconds_var, + "fudai_disable_content_recognition_var": fudai_disable_content_recognition_var, + "fudai_disable_task_recognition_var": fudai_disable_task_recognition_var, + "fudai_exit_after_misses_var": fudai_exit_after_misses_var, + "fudai_click_wait_seconds_var": fudai_click_wait_seconds_var, + "switch_room_wait_after_stage_diag_seconds_var": switch_room_wait_after_stage_diag_seconds_var, + "live_room_match_threshold_var": live_room_match_threshold_var, + "swipe_duration_ms_var": swipe_duration_ms_var, + "swipe_up_start_y_var": swipe_up_start_y_var, + "swipe_up_end_y_var": swipe_up_end_y_var, + "yg_enabled_var": yg_enabled_var, + "yg_actions_enabled_var": yg_actions_enabled_var, + "yg_only_var": yg_only_var, + "yg_recommend_duration_var": yg_recommend_duration_var, + "yg_recommend_interval_var": yg_recommend_interval_var, + "yg_like_prob_var": yg_like_prob_var, + "yg_fav_prob_var": yg_fav_prob_var, + "yg_comment_prob_var": yg_comment_prob_var, + "yg_dwell_on_action_min_var": yg_dwell_on_action_min_var, + "yg_dwell_on_action_max_var": yg_dwell_on_action_max_var, + "yg_icon_roi_size_var": yg_icon_roi_size_var, + "yg_icon_match_threshold_var": yg_icon_match_threshold_var, + "yg_step_screenshot_var": yg_step_screenshot_var, + "yg_like_roi_offset_x_var": yg_like_roi_offset_x_var, + "yg_like_roi_offset_y_var": yg_like_roi_offset_y_var, + "yg_fav_roi_offset_x_var": yg_fav_roi_offset_x_var, + "yg_fav_roi_offset_y_var": yg_fav_roi_offset_y_var, + "yg_like_icon_x_var": yg_like_icon_x_var, + "yg_like_icon_y_var": yg_like_icon_y_var, + "yg_fav_icon_x_var": yg_fav_icon_x_var, + "yg_fav_icon_y_var": yg_fav_icon_y_var, + "yg_like_template_path_var": yg_like_template_path_var, + "yg_fav_template_path_var": yg_fav_template_path_var, + "yg_after_dwell_direction_var": yg_after_dwell_direction_var, + "yg_after_dwell_distance_var": yg_after_dwell_distance_var, + "yg_comment_btn_x_var": yg_comment_btn_x_var, + "yg_comment_btn_y_var": yg_comment_btn_y_var, + "yg_comment_input_x_var": yg_comment_input_x_var, + "yg_comment_input_y_var": yg_comment_input_y_var, + "yg_comment_send_x_var": yg_comment_send_x_var, + "yg_comment_send_y_var": yg_comment_send_y_var, + "yg_comment_close_x_var": yg_comment_close_x_var, + "yg_comment_close_y_var": yg_comment_close_y_var, + "fudai_quiet_hours_enabled_var": fudai_quiet_hours_enabled_var, + "fudai_quiet_start_hour_var": fudai_quiet_start_hour_var, + "fudai_quiet_end_hour_var": fudai_quiet_end_hour_var, + "stage_diag_max_time_var": stage_diag_max_time_var, + "stage_diag_max_step_time_var": stage_diag_max_step_time_var, + "stage_diag_verbose_var": stage_diag_verbose_var, + "enable_ocr_mode1_var": enable_ocr_mode1_var, + "fudai_template_match_enabled_var": fudai_template_match_enabled_var, + "fudai_template_match_threshold_var": fudai_template_match_threshold_var, + "fudai_detail_template_threshold_var": fudai_detail_template_threshold_var, + "lucky_draw_red_ratio_threshold_var": lucky_draw_red_ratio_threshold_var, + "coupon_template_match_threshold_var": coupon_template_match_threshold_var, + "attend_button_red_ratio_threshold_var": attend_button_red_ratio_threshold_var, + "fansclub_join_red_ratio_threshold_var": fansclub_join_red_ratio_threshold_var, + "shopping_redpacket_red_ratio_threshold_var": shopping_redpacket_red_ratio_threshold_var, + "debug_captures_enabled_var": debug_captures_enabled_var, + "debug_captures_auto_cleanup_var": debug_captures_auto_cleanup_var, + "debug_captures_keep_days_var": debug_captures_keep_days_var, + "debug_captures_max_files_var": debug_captures_max_files_var, + "debug_captures_async_save_var": debug_captures_async_save_var, + "debug_captures_log_on_complete_var": debug_captures_log_on_complete_var, + "debug_async_success_var": debug_async_success_var, + "debug_async_failure_var": debug_async_failure_var, + "logging_beautify_var": logging_beautify_var, + "logging_color_var": logging_color_var, + "logging_show_timestamps_var": logging_show_timestamps_var, + "logging_use_dated_logs_var": logging_use_dated_logs_var, + "logging_enable_monitor_var": logging_enable_monitor_var, + "log_unified_enabled_var": log_unified_enabled_var, + "log_unified_path_var": log_unified_path_var, + "logging_keep_days_var": logging_keep_days_var, + "logging_compress_logs_var": logging_compress_logs_var, + "logging_max_total_size_gb_var": logging_max_total_size_gb_var, + "logging_compress_after_days_var": logging_compress_after_days_var, + "logging_performance_enabled_var": logging_performance_enabled_var, + "logging_track_functions_var": logging_track_functions_var, + "logging_debug_level_var": logging_debug_level_var, + "logging_error_level_var": logging_error_level_var, + "logging_action_format_var": logging_action_format_var, + "logging_format_mode_var": logging_format_mode_var, + "logging_monitor_warning_mb_var": logging_monitor_warning_mb_var, + "logging_monitor_critical_mb_var": logging_monitor_critical_mb_var, + "gui_theme_var": gui_theme_var, + "gui_realtime_refresh_interval_ms_var": gui_realtime_refresh_interval_ms_var, + "gui_realtime_tail_items_var": gui_realtime_tail_items_var, + "skip_lt_seconds_var": skip_lt_seconds_var, + } diff --git a/gui/gui_app.py b/gui/gui_app.py index ac27a34..b433c25 100644 --- a/gui/gui_app.py +++ b/gui/gui_app.py @@ -103,6 +103,7 @@ from gui.components.preview_tab import setup_preview_tab from gui.components.keywords_tab import setup_keywords_tab from gui.components.main_notebook import setup_main_notebook from gui.components.action_buttons import setup_action_buttons +from gui.components.config_vars import build_config_vars # 导入日志颜色配置模块 try: @@ -326,7 +327,136 @@ def main(): # 配置区(提前读取配置,供后续使用) cfg = read_config() - y_var = tk.IntVar(value=int(cfg.get("y_pianyi", 0) or 0)) + _vars_ = build_config_vars(cfg) + y_var = _vars_["y_var"] + enable_back_on_misses_var = _vars_["enable_back_on_misses_var"] + swipe_down_back_enabled_var = _vars_["swipe_down_back_enabled_var"] + swipe_down_back_count_var = _vars_["swipe_down_back_count_var"] + needswitch_var = _vars_["needswitch_var"] + infinite_loop_var = _vars_["infinite_loop_var"] + wait_minutes_var = _vars_["wait_minutes_var"] + min_value_var = _vars_["min_value_var"] + min_participants_var = _vars_["min_participants_var"] + max_participants_var = _vars_["max_participants_var"] + skip_gt_seconds_var = _vars_["skip_gt_seconds_var"] + reset_after_swipes_enabled_var = _vars_["reset_after_swipes_enabled_var"] + reset_after_swipes_var = _vars_["reset_after_swipes_var"] + reset_after_swipes_action_var = _vars_["reset_after_swipes_action_var"] + streaming_enabled_var = _vars_["streaming_enabled_var"] + auto_join_var = _vars_["auto_join_var"] + fansclub_action_var = _vars_["fansclub_action_var"] + fansclub_click_delay_var = _vars_["fansclub_click_delay_var"] + fansclub_auto_wait_var = _vars_["fansclub_auto_wait_var"] + fansclub_manual_wait_var = _vars_["fansclub_manual_wait_var"] + high_value_fudai_enabled_var = _vars_["high_value_fudai_enabled_var"] + high_value_fudai_threshold_yuan_var = _vars_["high_value_fudai_threshold_yuan_var"] + high_value_fudai_join_ahead_seconds_var = _vars_["high_value_fudai_join_ahead_seconds_var"] + high_value_fudai_max_swipe_back_var = _vars_["high_value_fudai_max_swipe_back_var"] + high_value_fudai_max_reservations_var = _vars_["high_value_fudai_max_reservations_var"] + high_value_fudai_after_action_var = _vars_["high_value_fudai_after_action_var"] + high_value_fudai_poll_before_seconds_var = _vars_["high_value_fudai_poll_before_seconds_var"] + high_value_room_revisit_enabled_var = _vars_["high_value_room_revisit_enabled_var"] + high_value_room_revisit_only_current_run_var = _vars_["high_value_room_revisit_only_current_run_var"] + high_value_room_revisit_min_interval_seconds_var = _vars_["high_value_room_revisit_min_interval_seconds_var"] + high_value_room_revisit_max_per_run_var = _vars_["high_value_room_revisit_max_per_run_var"] + high_value_room_revisit_min_prize_value_var = _vars_["high_value_room_revisit_min_prize_value_var"] + high_value_room_revisit_max_age_days_var = _vars_["high_value_room_revisit_max_age_days_var"] + reservation_back_verify_enabled_var = _vars_["reservation_back_verify_enabled_var"] + reservation_back_swipe_delay_var = _vars_["reservation_back_swipe_delay_var"] + reservation_back_verify_wait_seconds_var = _vars_["reservation_back_verify_wait_seconds_var"] + fudai_find_max_attempts_var = _vars_["fudai_find_max_attempts_var"] + fudai_icon_retry_delay_seconds_var = _vars_["fudai_icon_retry_delay_seconds_var"] + fudai_icon_max_wait_seconds_var = _vars_["fudai_icon_max_wait_seconds_var"] + fudai_disable_content_recognition_var = _vars_["fudai_disable_content_recognition_var"] + fudai_disable_task_recognition_var = _vars_["fudai_disable_task_recognition_var"] + fudai_exit_after_misses_var = _vars_["fudai_exit_after_misses_var"] + fudai_click_wait_seconds_var = _vars_["fudai_click_wait_seconds_var"] + switch_room_wait_after_stage_diag_seconds_var = _vars_["switch_room_wait_after_stage_diag_seconds_var"] + live_room_match_threshold_var = _vars_["live_room_match_threshold_var"] + swipe_duration_ms_var = _vars_["swipe_duration_ms_var"] + swipe_up_start_y_var = _vars_["swipe_up_start_y_var"] + swipe_up_end_y_var = _vars_["swipe_up_end_y_var"] + yg_enabled_var = _vars_["yg_enabled_var"] + yg_actions_enabled_var = _vars_["yg_actions_enabled_var"] + yg_only_var = _vars_["yg_only_var"] + yg_recommend_duration_var = _vars_["yg_recommend_duration_var"] + yg_recommend_interval_var = _vars_["yg_recommend_interval_var"] + yg_like_prob_var = _vars_["yg_like_prob_var"] + yg_fav_prob_var = _vars_["yg_fav_prob_var"] + yg_comment_prob_var = _vars_["yg_comment_prob_var"] + yg_dwell_on_action_min_var = _vars_["yg_dwell_on_action_min_var"] + yg_dwell_on_action_max_var = _vars_["yg_dwell_on_action_max_var"] + yg_icon_roi_size_var = _vars_["yg_icon_roi_size_var"] + yg_icon_match_threshold_var = _vars_["yg_icon_match_threshold_var"] + yg_step_screenshot_var = _vars_["yg_step_screenshot_var"] + yg_like_roi_offset_x_var = _vars_["yg_like_roi_offset_x_var"] + yg_like_roi_offset_y_var = _vars_["yg_like_roi_offset_y_var"] + yg_fav_roi_offset_x_var = _vars_["yg_fav_roi_offset_x_var"] + yg_fav_roi_offset_y_var = _vars_["yg_fav_roi_offset_y_var"] + yg_like_icon_x_var = _vars_["yg_like_icon_x_var"] + yg_like_icon_y_var = _vars_["yg_like_icon_y_var"] + yg_fav_icon_x_var = _vars_["yg_fav_icon_x_var"] + yg_fav_icon_y_var = _vars_["yg_fav_icon_y_var"] + yg_like_template_path_var = _vars_["yg_like_template_path_var"] + yg_fav_template_path_var = _vars_["yg_fav_template_path_var"] + yg_after_dwell_direction_var = _vars_["yg_after_dwell_direction_var"] + yg_after_dwell_distance_var = _vars_["yg_after_dwell_distance_var"] + yg_comment_btn_x_var = _vars_["yg_comment_btn_x_var"] + yg_comment_btn_y_var = _vars_["yg_comment_btn_y_var"] + yg_comment_input_x_var = _vars_["yg_comment_input_x_var"] + yg_comment_input_y_var = _vars_["yg_comment_input_y_var"] + yg_comment_send_x_var = _vars_["yg_comment_send_x_var"] + yg_comment_send_y_var = _vars_["yg_comment_send_y_var"] + yg_comment_close_x_var = _vars_["yg_comment_close_x_var"] + yg_comment_close_y_var = _vars_["yg_comment_close_y_var"] + fudai_quiet_hours_enabled_var = _vars_["fudai_quiet_hours_enabled_var"] + fudai_quiet_start_hour_var = _vars_["fudai_quiet_start_hour_var"] + fudai_quiet_end_hour_var = _vars_["fudai_quiet_end_hour_var"] + stage_diag_max_time_var = _vars_["stage_diag_max_time_var"] + stage_diag_max_step_time_var = _vars_["stage_diag_max_step_time_var"] + stage_diag_verbose_var = _vars_["stage_diag_verbose_var"] + enable_ocr_mode1_var = _vars_["enable_ocr_mode1_var"] + fudai_template_match_enabled_var = _vars_["fudai_template_match_enabled_var"] + fudai_template_match_threshold_var = _vars_["fudai_template_match_threshold_var"] + fudai_detail_template_threshold_var = _vars_["fudai_detail_template_threshold_var"] + lucky_draw_red_ratio_threshold_var = _vars_["lucky_draw_red_ratio_threshold_var"] + coupon_template_match_threshold_var = _vars_["coupon_template_match_threshold_var"] + attend_button_red_ratio_threshold_var = _vars_["attend_button_red_ratio_threshold_var"] + fansclub_join_red_ratio_threshold_var = _vars_["fansclub_join_red_ratio_threshold_var"] + shopping_redpacket_red_ratio_threshold_var = _vars_["shopping_redpacket_red_ratio_threshold_var"] + debug_captures_enabled_var = _vars_["debug_captures_enabled_var"] + debug_captures_auto_cleanup_var = _vars_["debug_captures_auto_cleanup_var"] + debug_captures_keep_days_var = _vars_["debug_captures_keep_days_var"] + debug_captures_max_files_var = _vars_["debug_captures_max_files_var"] + debug_captures_async_save_var = _vars_["debug_captures_async_save_var"] + debug_captures_log_on_complete_var = _vars_["debug_captures_log_on_complete_var"] + debug_async_success_var = _vars_["debug_async_success_var"] + debug_async_failure_var = _vars_["debug_async_failure_var"] + logging_beautify_var = _vars_["logging_beautify_var"] + logging_color_var = _vars_["logging_color_var"] + logging_show_timestamps_var = _vars_["logging_show_timestamps_var"] + logging_use_dated_logs_var = _vars_["logging_use_dated_logs_var"] + logging_enable_monitor_var = _vars_["logging_enable_monitor_var"] + log_unified_enabled_var = _vars_["log_unified_enabled_var"] + log_unified_path_var = _vars_["log_unified_path_var"] + logging_keep_days_var = _vars_["logging_keep_days_var"] + logging_compress_logs_var = _vars_["logging_compress_logs_var"] + logging_max_total_size_gb_var = _vars_["logging_max_total_size_gb_var"] + logging_compress_after_days_var = _vars_["logging_compress_after_days_var"] + logging_performance_enabled_var = _vars_["logging_performance_enabled_var"] + logging_track_functions_var = _vars_["logging_track_functions_var"] + logging_debug_level_var = _vars_["logging_debug_level_var"] + logging_error_level_var = _vars_["logging_error_level_var"] + logging_action_format_var = _vars_["logging_action_format_var"] + logging_format_mode_var = _vars_["logging_format_mode_var"] + logging_monitor_warning_mb_var = _vars_["logging_monitor_warning_mb_var"] + logging_monitor_critical_mb_var = _vars_["logging_monitor_critical_mb_var"] + gui_theme_var = _vars_["gui_theme_var"] + gui_realtime_refresh_interval_ms_var = _vars_["gui_realtime_refresh_interval_ms_var"] + gui_realtime_tail_items_var = _vars_["gui_realtime_tail_items_var"] + skip_lt_seconds_var = _vars_["skip_lt_seconds_var"] + + ttk.Label(top, text="Y偏移:").pack(side=LEFT) ttk.Spinbox(top, from_=-200, to=200, textvariable=y_var, width=6).pack( side=LEFT, padx=(0, 12) @@ -334,15 +464,6 @@ def main(): # 连续无福袋退出阈值变量(提前声明,实际声明在下方唯一位置以便与配置同步) # (变量将在后面统一声明,避免重复创建 IntVar 导致绑定不一致) # 启用返回键回退开关变量(提前声明) - enable_back_on_misses_var = tk.BooleanVar( - value=bool(cfg.get("enable_back_on_misses", True)) - ) - swipe_down_back_enabled_var = tk.BooleanVar( - value=bool(cfg.get("swipe_down_back_enabled", False)) - ) - swipe_down_back_count_var = tk.IntVar( - value=int(cfg.get("swipe_down_back_count", 3) or 3) - ) # 中部:左侧配置(使用Notebook标签页)+ 右侧日志/预览(支持拖拽调整宽度) mid = ttk.PanedWindow(root, orient="horizontal") @@ -361,417 +482,33 @@ def main(): left_notebook.pack(fill=BOTH, expand=True) # 左侧 Notebook 中不再添加映射表页(已移至右侧) - needswitch_var = tk.BooleanVar(value=bool(cfg.get("needswitch", True))) - infinite_loop_var = tk.BooleanVar( - value=bool(cfg.get("infinite_loop_enabled", False)) - ) - wait_minutes_var = tk.IntVar(value=int(cfg.get("wait_minutes", 5) or 5)) - min_value_var = tk.DoubleVar(value=float(cfg.get("min_prize_value_yuan", 0) or 0)) - min_participants_var = tk.IntVar(value=int(cfg.get("min_participants", 0) or 0)) - max_participants_var = tk.IntVar(value=int(cfg.get("max_participants", 0) or 0)) - skip_gt_seconds_var = tk.IntVar( - value=int(cfg.get("skip_if_countdown_gt_seconds", 900) or 900) - ) - reset_after_swipes_enabled_var = tk.BooleanVar( - value=bool(cfg.get("reset_after_swipes_enabled", False)) - ) - reset_after_swipes_var = tk.IntVar( - value=int(cfg.get("reset_after_swipes", 10) or 10) - ) - reset_after_swipes_action_var = tk.StringVar( - value=str(cfg.get("reset_after_swipes_action", "swipe") or "swipe") - ) - enable_back_on_misses_var = tk.BooleanVar( - value=bool(cfg.get("enable_back_on_misses", True)) - ) # 流式后台截图开关(默认启用) - streaming_enabled_var = tk.BooleanVar( - value=bool(cfg.get("enable_streaming_screenshot", True)) - ) # 按需求:删除"自动养号/随机等待/轻微扰动/定时休息"等设置,仅保留"推荐页养号(爱心/收藏/评论)"配置。 - auto_join_var = tk.BooleanVar(value=bool(cfg.get("auto_join_fansclub", False))) - fansclub_action_var = tk.StringVar( - value=str(cfg.get("fansclub_fail_action", "stay") or "stay").lower() - ) - fansclub_click_delay_var = tk.DoubleVar( - value=float(cfg.get("fansclub_click_delay", 0.6) or 0.6) - ) - fansclub_auto_wait_var = tk.DoubleVar( - value=float(cfg.get("fansclub_auto_join_wait_seconds", 5.0) or 5.0) - ) - fansclub_manual_wait_var = tk.DoubleVar( - value=float(cfg.get("fansclub_manual_wait_seconds", 3.0) or 3.0) - ) # Web端新增配置变量 - 高价值预约相关 - high_value_fudai_enabled_var = tk.BooleanVar( - value=bool(cfg.get("high_value_fudai_enabled", False)) - ) - high_value_fudai_threshold_yuan_var = tk.DoubleVar( - value=float(cfg.get("high_value_fudai_threshold_yuan", 1000) or 1000) - ) - high_value_fudai_join_ahead_seconds_var = tk.IntVar( - value=int(cfg.get("high_value_fudai_join_ahead_seconds", 300) or 300) - ) - high_value_fudai_max_swipe_back_var = tk.IntVar( - value=int(cfg.get("high_value_fudai_max_swipe_back", 60) or 60) - ) - high_value_fudai_max_reservations_var = tk.IntVar( - value=int(cfg.get("high_value_fudai_max_reservations", 5) or 5) - ) - high_value_fudai_after_action_var = tk.StringVar( - value=str(cfg.get("high_value_fudai_after_action", "continue") or "continue") - ) - high_value_fudai_poll_before_seconds_var = tk.DoubleVar( - value=float(cfg.get("high_value_fudai_poll_before_seconds", 10.0) or 10.0) - ) - high_value_room_revisit_enabled_var = tk.BooleanVar( - value=bool(cfg.get("high_value_room_revisit_enabled", True)) - ) - high_value_room_revisit_only_current_run_var = tk.BooleanVar( - value=bool(cfg.get("high_value_room_revisit_only_current_run", False)) - ) - high_value_room_revisit_min_interval_seconds_var = tk.IntVar( - value=int(cfg.get("high_value_room_revisit_min_interval_seconds", 300)) - ) - high_value_room_revisit_max_per_run_var = tk.IntVar( - value=int(cfg.get("high_value_room_revisit_max_per_run", 5)) - ) - high_value_room_revisit_min_prize_value_var = tk.DoubleVar( - value=float(cfg.get("high_value_room_revisit_min_prize_value", 0.0)) - ) - high_value_room_revisit_max_age_days_var = tk.IntVar( - value=int(cfg.get("high_value_room_revisit_max_age_days", 30)) - ) - reservation_back_verify_enabled_var = tk.BooleanVar( - value=bool(cfg.get("reservation_back_verify_enabled", True)) - ) - reservation_back_swipe_delay_var = tk.DoubleVar( - value=float(cfg.get("reservation_back_swipe_delay", 0) or 0) - ) - reservation_back_verify_wait_seconds_var = tk.DoubleVar( - value=float(cfg.get("reservation_back_verify_wait_seconds", 5.0) or 5.0) - ) - fudai_find_max_attempts_var = tk.IntVar( - value=int(cfg.get("fudai_find_max_attempts", 0) or 0) - ) - fudai_icon_retry_delay_seconds_var = tk.DoubleVar( - value=float(cfg.get("fudai_icon_retry_delay_seconds", 0.6) or 0.6) - ) - fudai_icon_max_wait_seconds_var = tk.DoubleVar( - value=float(cfg.get("fudai_icon_max_wait_seconds", 5.0) or 5.0) - ) - fudai_disable_content_recognition_var = tk.BooleanVar( - value=bool(cfg.get("fudai_disable_content_recognition", False)) - ) - fudai_disable_task_recognition_var = tk.BooleanVar( - value=bool(cfg.get("fudai_disable_task_recognition", False)) - ) - fudai_exit_after_misses_var = tk.IntVar( - value=int(cfg.get("fudai_exit_after_misses", 30) or 30) - ) - fudai_click_wait_seconds_var = tk.DoubleVar( - value=float(cfg.get("fudai_click_wait_seconds", 1.0) or 1.0) - ) - switch_room_wait_after_stage_diag_seconds_var = tk.DoubleVar( - value=float(cfg.get("switch_room_wait_after_stage_diag_seconds", 7.0) or 7.0) - ) - live_room_match_threshold_var = tk.DoubleVar( - value=float(cfg.get("live_room_match_threshold", 0.8) or 0.8) - ) # 滑动速度(毫秒) - swipe_duration_ms_var = tk.IntVar( - value=int(cfg.get("swipe_duration_ms", 600) or 600) - ) # 滑动坐标配置 - swipe_up_start_y_var = tk.IntVar( - value=int(cfg.get("swipe_up_start_y", 1200) or 1200) - ) - swipe_up_end_y_var = tk.IntVar(value=int(cfg.get("swipe_up_end_y", 600) or 600)) # 推荐页养号:爱心/收藏/评论(基于图标模板匹配 + 坐标点击) - yg_enabled_var = tk.BooleanVar(value=bool(cfg.get("yanghao_enabled", True))) - yg_actions_enabled_var = tk.BooleanVar( - value=bool(cfg.get("yanghao_enable_actions", True)) - ) - yg_only_var = tk.BooleanVar(value=bool(cfg.get("yanghao_only", False))) - yg_recommend_duration_var = tk.IntVar( - value=int(cfg.get("yanghao_recommend_duration_seconds", 60) or 60) - ) - yg_recommend_interval_var = tk.IntVar( - value=int(cfg.get("yanghao_recommend_interval_seconds", 0) or 0) - ) - yg_like_prob_var = tk.DoubleVar( - value=float(cfg.get("yanghao_like_prob", 0.0) or 0.0) - ) - yg_fav_prob_var = tk.DoubleVar(value=float(cfg.get("yanghao_fav_prob", 0.0) or 0.0)) - yg_comment_prob_var = tk.DoubleVar( - value=float(cfg.get("yanghao_comment_prob", 0.0) or 0.0) - ) - yg_dwell_on_action_min_var = tk.DoubleVar( - value=float(cfg.get("yanghao_dwell_on_action_min_seconds", 5) or 5) - ) - yg_dwell_on_action_max_var = tk.DoubleVar( - value=float(cfg.get("yanghao_dwell_on_action_max_seconds", 30) or 30) - ) - yg_icon_roi_size_var = tk.IntVar( - value=int(cfg.get("yanghao_icon_roi_size", 240) or 240) - ) - yg_icon_match_threshold_var = tk.DoubleVar( - value=float(cfg.get("yanghao_icon_match_threshold", 0.72) or 0.72) - ) - yg_step_screenshot_var = tk.BooleanVar( - value=bool(cfg.get("yanghao_step_screenshot", False)) - ) - yg_like_roi_offset_x_var = tk.IntVar( - value=int(cfg.get("yanghao_like_roi_offset_x", 0) or 0) - ) - yg_like_roi_offset_y_var = tk.IntVar( - value=int(cfg.get("yanghao_like_roi_offset_y", 0) or 0) - ) - yg_fav_roi_offset_x_var = tk.IntVar( - value=int(cfg.get("yanghao_fav_roi_offset_x", 0) or 0) - ) - yg_fav_roi_offset_y_var = tk.IntVar( - value=int(cfg.get("yanghao_fav_roi_offset_y", 0) or 0) - ) - yg_like_icon_x_var = tk.IntVar(value=int(cfg.get("yanghao_like_icon_x", 0) or 0)) - yg_like_icon_y_var = tk.IntVar(value=int(cfg.get("yanghao_like_icon_y", 0) or 0)) - yg_fav_icon_x_var = tk.IntVar(value=int(cfg.get("yanghao_fav_icon_x", 0) or 0)) - yg_fav_icon_y_var = tk.IntVar(value=int(cfg.get("yanghao_fav_icon_y", 0) or 0)) - yg_like_template_path_var = tk.StringVar( - value=str( - cfg.get("yanghao_like_template_path", "assets/like.png") - or "assets/like.png" - ) - ) - yg_fav_template_path_var = tk.StringVar( - value=str( - cfg.get("yanghao_fav_template_path", "assets/fav.png") or "assets/fav.png" - ) - ) - yg_like_icon_x_var = tk.IntVar(value=int(cfg.get("yanghao_like_icon_x", 0) or 0)) - yg_like_icon_y_var = tk.IntVar(value=int(cfg.get("yanghao_like_icon_y", 0) or 0)) - yg_fav_icon_x_var = tk.IntVar(value=int(cfg.get("yanghao_fav_icon_x", 0) or 0)) - yg_fav_icon_y_var = tk.IntVar(value=int(cfg.get("yanghao_fav_icon_y", 0) or 0)) - yg_after_dwell_direction_var = tk.StringVar( - value=str(cfg.get("yanghao_after_dwell_swipe_direction", "up") or "up") - ) - yg_after_dwell_distance_var = tk.IntVar( - value=int(cfg.get("yanghao_after_dwell_swipe_distance_px", 900) or 900) - ) - yg_comment_btn_x_var = tk.IntVar( - value=int(cfg.get("yanghao_comment_btn_x", 0) or 0) - ) - yg_comment_btn_y_var = tk.IntVar( - value=int(cfg.get("yanghao_comment_btn_y", 0) or 0) - ) - yg_comment_input_x_var = tk.IntVar( - value=int(cfg.get("yanghao_comment_input_x", 0) or 0) - ) - yg_comment_input_y_var = tk.IntVar( - value=int(cfg.get("yanghao_comment_input_y", 0) or 0) - ) - yg_comment_send_x_var = tk.IntVar( - value=int(cfg.get("yanghao_comment_send_x", 0) or 0) - ) - yg_comment_send_y_var = tk.IntVar( - value=int(cfg.get("yanghao_comment_send_y", 0) or 0) - ) - yg_comment_close_x_var = tk.IntVar( - value=int(cfg.get("yanghao_comment_close_x", 0) or 0) - ) - yg_comment_close_y_var = tk.IntVar( - value=int(cfg.get("yanghao_comment_close_y", 0) or 0) - ) - fudai_quiet_hours_enabled_var = tk.BooleanVar( - value=bool(cfg.get("fudai_quiet_hours_enabled", True)) - ) - fudai_quiet_start_hour_var = tk.IntVar( - value=int(cfg.get("fudai_quiet_start_hour", 2) or 2) - ) - fudai_quiet_end_hour_var = tk.IntVar( - value=int(cfg.get("fudai_quiet_end_hour", 7) or 7) - ) # 阶段诊断时间参数(用于调试) - stage_diag_max_time_var = tk.DoubleVar( - value=float(cfg.get("stage_diag_max_time", 10.0) or 10.0) - ) - stage_diag_max_step_time_var = tk.DoubleVar( - value=float(cfg.get("stage_diag_max_step_time", 2.0) or 2.0) - ) - stage_diag_verbose_var = tk.BooleanVar( - value=bool(cfg.get("logging", {}).get("stage_diag_verbose", True)) - ) - enable_ocr_mode1_var = tk.BooleanVar(value=bool(cfg.get("enable_ocr_mode1", False))) # 福袋模板匹配开关和阈值 - fudai_template_match_enabled_var = tk.BooleanVar( - value=bool(cfg.get("fudai_template_match_enabled", False)) - ) - fudai_template_match_threshold_var = tk.DoubleVar( - value=float(cfg.get("fudai_template_match_threshold", 0.7) or 0.7) - ) # 福袋详情页模板匹配阈值(0.0~1.0,默认0.7) - fudai_detail_template_threshold_var = tk.DoubleVar( - value=float(cfg.get("fudai_detail_template_threshold", 0.7) or 0.7) - ) # 开奖页面红色占比阈值(0.0~1.0,默认0.9) - lucky_draw_red_ratio_threshold_var = tk.DoubleVar( - value=float(cfg.get("lucky_draw_red_ratio_threshold", 0.9) or 0.9) - ) # 优惠券模板匹配阈值(0.0~1.0,默认0.75) - coupon_template_match_threshold_var = tk.DoubleVar( - value=float(cfg.get("coupon_template_match_threshold", 0.75) or 0.75) - ) # 参与按钮红色占比阈值(0.0~1.0,默认0.25) - attend_button_red_ratio_threshold_var = tk.DoubleVar( - value=float(cfg.get("attend_button_red_ratio_threshold", 0.25) or 0.25) - ) # 粉丝团加入红色占比阈值(0.0~1.0,默认0.25) - fansclub_join_red_ratio_threshold_var = tk.DoubleVar( - value=float(cfg.get("fansclub_join_red_ratio_threshold", 0.25) or 0.25) - ) # 购物红包背景红色占比阈值(0.0~1.0,默认0.15) - shopping_redpacket_red_ratio_threshold_var = tk.DoubleVar( - value=float(cfg.get("shopping_redpacket_red_ratio_threshold", 0.15) or 0.15) - ) # 调试图像开关 & 清理相关变量 - debug_captures_enabled_var = tk.BooleanVar( - value=bool( - cfg.get("debug_captures", {}).get("enabled", False) - if isinstance(cfg.get("debug_captures"), dict) - else False - ) - ) # 调试图像清理相关变量 - debug_captures_auto_cleanup_var = tk.BooleanVar( - value=bool( - cfg.get("debug_captures", {}).get("auto_cleanup", True) - if isinstance(cfg.get("debug_captures"), dict) - else True - ) - ) - debug_captures_keep_days_var = tk.IntVar( - value=int( - cfg.get("debug_captures", {}).get("keep_days", 7) - if isinstance(cfg.get("debug_captures"), dict) - else 7 - ) - ) - debug_captures_max_files_var = tk.IntVar( - value=int( - cfg.get("debug_captures", {}).get("max_files", 2000) - if isinstance(cfg.get("debug_captures"), dict) - else 2000 - ) - ) - debug_captures_async_save_var = tk.BooleanVar( - value=bool( - cfg.get("debug_captures", {}).get("async_save", True) - if isinstance(cfg.get("debug_captures"), dict) - else True - ) - ) - debug_captures_log_on_complete_var = tk.BooleanVar( - value=bool( - cfg.get("debug_captures", {}).get("log_on_complete", False) - if isinstance(cfg.get("debug_captures"), dict) - else False - ) - ) # 异步保存计数显示变量 - debug_async_success_var = tk.IntVar(value=0) - debug_async_failure_var = tk.IntVar(value=0) # 日志配置变量 - logging_beautify_var = tk.BooleanVar( - value=bool(cfg.get("logging", {}).get("beautify_output", True)) - ) - logging_color_var = tk.BooleanVar( - value=bool(cfg.get("logging", {}).get("color_output", True)) - ) - logging_show_timestamps_var = tk.BooleanVar( - value=bool(cfg.get("logging", {}).get("show_timestamps", True)) - ) - logging_use_dated_logs_var = tk.BooleanVar( - value=bool(cfg.get("logging", {}).get("use_dated_logs", True)) - ) - logging_enable_monitor_var = tk.BooleanVar( - value=bool(cfg.get("logging", {}).get("enable_monitor", True)) - ) - log_unified_enabled_var = tk.BooleanVar( - value=bool(cfg.get("log_unified_enabled", True)) - ) - log_unified_path_var = tk.StringVar( - value=str(cfg.get("log_unified_path", "logs/unified.log") or "logs/unified.log") - ) - logging_keep_days_var = tk.IntVar( - value=int(cfg.get("logging", {}).get("keep_days", 30) or 30) - ) - logging_compress_logs_var = tk.BooleanVar( - value=bool(cfg.get("logging", {}).get("compress_logs", True)) - ) - logging_max_total_size_gb_var = tk.DoubleVar( - value=float(cfg.get("logging", {}).get("max_total_size_gb", 10.0) or 10.0) - ) - logging_compress_after_days_var = tk.IntVar( - value=int(cfg.get("logging", {}).get("compress_after_days", 7) or 7) - ) - logging_performance_enabled_var = tk.BooleanVar( - value=bool( - cfg.get("logging", {}).get("performance_tracking", {}).get("enabled", True) - ) - ) - logging_track_functions_var = tk.BooleanVar( - value=bool( - cfg.get("logging", {}) - .get("performance_tracking", {}) - .get("track_function_calls", True) - ) - ) - logging_debug_level_var = tk.StringVar( - value=str(cfg.get("logging", {}).get("debug_detail_level", "normal")) - ) - logging_error_level_var = tk.StringVar( - value=str(cfg.get("logging", {}).get("error_detail_level", "full")) - ) - logging_action_format_var = tk.StringVar( - value=str(cfg.get("logging", {}).get("action_log_format", "concise")) - ) - logging_format_mode_var = tk.StringVar( - value=str(cfg.get("logging", {}).get("log_format_mode", "simple")) - ) - logging_monitor_warning_mb_var = tk.DoubleVar( - value=float(cfg.get("logging", {}).get("monitor_warning_mb", 500.0) or 500.0) - ) - logging_monitor_critical_mb_var = tk.DoubleVar( - value=float(cfg.get("logging", {}).get("monitor_critical_mb", 2000.0) or 2000.0) - ) # GUI 主题变量 - gui_theme_var = tk.StringVar( - value=str(cfg.get("gui", {}).get("theme", "litera") or "litera") - ) - gui_realtime_refresh_interval_ms_var = tk.IntVar( - value=int( - cfg.get("gui", {}) - .get("realtime_status", {}) - .get("refresh_interval_ms", 1000) - or 1000 - ) - ) - gui_realtime_tail_items_var = tk.IntVar( - value=int( - cfg.get("gui", {}).get("realtime_status", {}).get("tail_items", 50) or 50 - ) - ) # 倒计时小于阈值参数 - skip_lt_seconds_var = tk.IntVar( - value=int(cfg.get("skip_if_countdown_lt_seconds", 10) or 10) - ) # 创建左侧配置标签页 # 标签页1:运行设置