From c5f947e14ac89bac620fcd85e872ec358ce3eb61 Mon Sep 17 00:00:00 2001 From: DLmaster361 Date: Thu, 31 Jul 2025 13:39:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E9=9D=99=E9=BB=98?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B=E6=A0=87=E8=AE=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/config.py | 8 ++++---- app/core/task_manager.py | 4 ++-- app/core/timer.py | 11 +++++++---- app/models/MAA.py | 17 +++++------------ app/models/general.py | 21 +++++++-------------- app/ui/dispatch_center.py | 8 ++++---- app/ui/queue_manager.py | 6 +++--- resources/version.json | 3 ++- 8 files changed, 34 insertions(+), 44 deletions(-) diff --git a/app/core/config.py b/app/core/config.py index f9333c6..1d5bc2d 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -275,11 +275,11 @@ class QueueConfig(LQConfig): def __init__(self) -> None: super().__init__() - self.queueSet_Name = ConfigItem("QueueSet", "Name", "") - self.queueSet_TimeEnabled = ConfigItem( + self.QueueSet_Name = ConfigItem("QueueSet", "Name", "") + self.QueueSet_TimeEnabled = ConfigItem( "QueueSet", "TimeEnabled", False, BoolValidator() ) - self.queueSet_AfterAccomplish = OptionsConfigItem( + self.QueueSet_AfterAccomplish = OptionsConfigItem( "QueueSet", "AfterAccomplish", "NoAction", @@ -705,7 +705,7 @@ class AppConfig(GlobalConfig): self.main_window = None self.PASSWORD = "" self.running_list = [] - self.silence_list = [] + self.silence_dict: Dict[Path, datetime] = {} self.info_bar_list = [] self.stage_dict = { "ALL": {"value": [], "text": []}, diff --git a/app/core/task_manager.py b/app/core/task_manager.py index c9d8a41..c044767 100644 --- a/app/core/task_manager.py +++ b/app/core/task_manager.py @@ -380,14 +380,14 @@ class _TaskManager(QObject): # 根据调度队列情况设置电源状态 if ( Config.queue_dict[name]["Config"].get( - Config.queue_dict[name]["Config"].queueSet_AfterAccomplish + Config.queue_dict[name]["Config"].QueueSet_AfterAccomplish ) != "NoAction" and Config.power_sign == "NoAction" ): Config.set_power_sign( Config.queue_dict[name]["Config"].get( - Config.queue_dict[name]["Config"].queueSet_AfterAccomplish + Config.queue_dict[name]["Config"].QueueSet_AfterAccomplish ) ) diff --git a/app/core/timer.py b/app/core/timer.py index c8a8e62..66d8dee 100644 --- a/app/core/timer.py +++ b/app/core/timer.py @@ -79,7 +79,7 @@ class _MainTimer(QObject): for name, info in Config.queue_dict.items(): - if not info["Config"].get(info["Config"].queueSet_TimeEnabled): + if not info["Config"].get(info["Config"].QueueSet_TimeEnabled): continue data = info["Config"].toDict() @@ -114,9 +114,12 @@ class _MainTimer(QObject): emulator_windows = [] for window in windows: - for emulator_path in Config.silence_list: - # 此处排除雷电名为新通知的窗口 - if str(emulator_path) in window and window[0] != "新通知": + for emulator_path, endtime in Config.silence_dict.items(): + if ( + datetime.now() < endtime + and str(emulator_path) in window + and window[0] != "新通知" # 此处排除雷电名为新通知的窗口 + ): emulator_windows.append(window) if emulator_windows: diff --git a/app/models/MAA.py b/app/models/MAA.py index c08b20b..f614150 100644 --- a/app/models/MAA.py +++ b/app/models/MAA.py @@ -570,12 +570,14 @@ class MaaManager(QObject): self.if_open_emulator = True break - # 添加静默进程标记 + # 更新静默进程标记有效时间 logger.info( - f"添加静默进程标记:{self.emulator_path}", + f"更新静默进程标记:{self.emulator_path},标记有效时间:{datetime.now() + timedelta(seconds=self.wait_time + 10)}", module=f"MAA调度器-{self.name}", ) - Config.silence_list.append(self.emulator_path) + Config.silence_dict[self.emulator_path] = ( + datetime.now() + timedelta(seconds=self.wait_time + 10) + ) self.search_ADB_address() @@ -1082,15 +1084,6 @@ class MaaManager(QObject): if self.isInterruptionRequested: return None - # 10s后移除静默进程标记 - QTimer.singleShot( - 10000, partial(Config.silence_list.remove, self.emulator_path) - ) - logger.info( - f"10s后移除静默进程标记:{self.emulator_path}", - module=f"MAA调度器-{self.name}", - ) - if "-" in self.ADB_address: ADB_ip = f"{self.ADB_address.split("-")[0]}-" ADB_port = int(self.ADB_address.split("-")[1]) diff --git a/app/models/general.py b/app/models/general.py index 67cdc83..3cc169e 100644 --- a/app/models/general.py +++ b/app/models/general.py @@ -317,13 +317,17 @@ class GeneralManager(QObject): self.script_result = "游戏/模拟器启动失败" break - # 添加静默进程标记 + # 更新静默进程标记 if self.set["Game"]["Style"] == "Emulator": logger.info( - f"添加静默进程标记:{self.game_path}", + f"更新静默进程标记:{self.game_path},标记有效时间:{datetime.now() + timedelta(seconds=self.set['Game']['WaitTime'] + 10)}", module=f"通用调度器-{self.name}", ) - Config.silence_list.append(self.game_path) + Config.silence_dict[ + self.game_path + ] = datetime.now() + timedelta( + seconds=self.set["Game"]["WaitTime"] + 10 + ) self.update_log_text.emit( f"正在等待游戏/模拟器完成启动\n请等待{self.set['Game']['WaitTime']}s" @@ -331,17 +335,6 @@ class GeneralManager(QObject): self.sleep(self.set["Game"]["WaitTime"]) - # 10s后移除静默进程标记 - if self.set["Game"]["Style"] == "Emulator": - logger.info( - f"10s后移除静默进程标记:{self.game_path}", - module=f"通用调度器-{self.name}", - ) - QTimer.singleShot( - 10000, - partial(Config.silence_list.remove, self.game_path), - ) - # 运行脚本任务 logger.info( f"运行脚本任务:{self.script_exe_path},参数:{self.set['Script']['Arguments']}", diff --git a/app/ui/dispatch_center.py b/app/ui/dispatch_center.py index 8e9ce40..3993dfa 100644 --- a/app/ui/dispatch_center.py +++ b/app/ui/dispatch_center.py @@ -240,8 +240,8 @@ class DispatchCenter(QWidget): self.script_list["主调度台"].top_bar.object.addItem( ( "队列" - if info["Config"].get(info["Config"].queueSet_Name) == "" - else f"队列 - {info["Config"].get(info["Config"].queueSet_Name)}" + if info["Config"].get(info["Config"].QueueSet_Name) == "" + else f"队列 - {info["Config"].get(info["Config"].QueueSet_Name)}" ), userData=name, ) @@ -312,8 +312,8 @@ class DispatchCenter(QWidget): continue text_list.append( "队列" - if info["Config"].get(info["Config"].queueSet_Name) == "" - else f"队列 - {info["Config"].get(info["Config"].queueSet_Name)}" + if info["Config"].get(info["Config"].QueueSet_Name) == "" + else f"队列 - {info["Config"].get(info["Config"].QueueSet_Name)}" ) data_list.append(name) diff --git a/app/ui/queue_manager.py b/app/ui/queue_manager.py index d6d477b..59accbf 100644 --- a/app/ui/queue_manager.py +++ b/app/ui/queue_manager.py @@ -399,7 +399,7 @@ class QueueManager(QWidget): content="用于标识调度队列的名称", text="请输入调度队列名称", qconfig=self.config, - configItem=self.config.queueSet_Name, + configItem=self.config.QueueSet_Name, parent=self, ) self.card_Enable = SwitchSettingCard( @@ -407,7 +407,7 @@ class QueueManager(QWidget): title="定时运行状态", content="调度队列定时运行状态,仅启用时会执行定时任务", qconfig=self.config, - configItem=self.config.queueSet_TimeEnabled, + configItem=self.config.QueueSet_TimeEnabled, parent=self, ) self.card_AfterAccomplish = ComboBoxSettingCard( @@ -423,7 +423,7 @@ class QueueManager(QWidget): "关机(强制)", ], qconfig=self.config, - configItem=self.config.queueSet_AfterAccomplish, + configItem=self.config.QueueSet_AfterAccomplish, parent=self, ) diff --git a/resources/version.json b/resources/version.json index 2d94d2b..e3a97ce 100644 --- a/resources/version.json +++ b/resources/version.json @@ -3,7 +3,8 @@ "version_info": { "4.4.1.5": { "程序优化": [ - "优化调度队列配置逻辑" + "优化调度队列配置逻辑", + "优化静默进程标记逻辑,避免未能及时移除导致相关功能持续开启" ] }, "4.4.1.4": {