From f4b45e9eae8b97e30dd2f8f2fbb48ddd91017c55 Mon Sep 17 00:00:00 2001 From: DLmaster361 Date: Thu, 31 Jul 2025 20:01:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(general):=20=E9=80=9A=E7=94=A8=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=90=AF=E5=8A=A8=E9=99=84=E5=8A=A0=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A2=9D=E5=A4=96=E7=9A=84=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=E4=BB=A5=E9=80=82=E5=BA=94UI=E5=8F=AF=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8E=E4=BB=BB=E5=8A=A1=E5=8F=AF=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=96=87=E4=BB=B6=E4=B8=8D=E5=90=8C=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/general.py | 45 ++++++++++++++++++++++++++++++++++------ app/ui/script_manager.py | 16 +++++++------- resources/version.json | 3 ++- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/app/models/general.py b/app/models/general.py index a17a77e..8ef8d15 100644 --- a/app/models/general.py +++ b/app/models/general.py @@ -140,7 +140,35 @@ class GeneralManager(QObject): """提取配置信息""" self.script_root_path = Path(self.set["Script"]["RootPath"]) - self.script_exe_path = Path(self.set["Script"]["ScriptPath"]) + self.script_path = Path(self.set["Script"]["ScriptPath"]) + + arguments_list = [] + path_list = [] + + for argument in [ + _.strip() + for _ in str(self.set["Script"]["Arguments"]).split("|") + if _.strip() + ]: + arg = [_.strip() for _ in argument.split("%") if _.strip()] + if len(arg) > 1: + path_list.append((self.script_path / arg[0]).resolve()) + arguments_list.append( + [_.strip() for _ in arg[1].split(" ") if _.strip()] + ) + elif len(arg) > 0: + path_list.append(self.script_path) + arguments_list.append( + [_.strip() for _ in arg[0].split(" ") if _.strip()] + ) + + self.script_exe_path = path_list[0] if len(path_list) > 0 else self.script_path + self.script_arguments = arguments_list[0] if len(arguments_list) > 0 else [] + self.script_set_exe_path = ( + path_list[1] if len(path_list) > 1 else self.script_path + ) + self.script_set_arguments = arguments_list[1] if len(arguments_list) > 1 else [] + self.script_config_path = Path(self.set["Script"]["ConfigPath"]) self.script_log_path = ( Path(self.set["Script"]["LogPath"]).with_stem( @@ -353,12 +381,12 @@ class GeneralManager(QObject): # 运行脚本任务 logger.info( - f"运行脚本任务:{self.script_exe_path},参数:{self.set['Script']['Arguments']}", + f"运行脚本任务:{self.script_exe_path},参数:{self.script_arguments}", module=f"通用调度器-{self.name}", ) self.script_process_manager.open_process( self.script_exe_path, - str(self.set["Script"]["Arguments"]).split(" "), + self.script_arguments, tracking_time=60 if self.set["Script"]["IfTrackProcess"] else 0, ) @@ -437,6 +465,7 @@ class GeneralManager(QObject): module=f"通用调度器-{self.name}", ) self.script_process_manager.kill() + System.kill_process(self.script_exe_path) if self.set["Game"]["Enabled"]: logger.info( f"中止游戏/模拟器进程:{list(self.game_process_manager.tracked_pids)}", @@ -554,11 +583,12 @@ class GeneralManager(QObject): try: # 创建通用脚本任务 logger.info( - f"无参数启动通用脚本:{self.script_exe_path}", + f"运行脚本任务:{self.script_set_exe_path},参数:{self.script_set_arguments}", module=f"通用调度器-{self.name}", ) self.script_process_manager.open_process( - self.script_exe_path, + self.script_set_exe_path, + self.script_set_arguments, tracking_time=60 if self.set["Script"]["IfTrackProcess"] else 0, ) @@ -913,7 +943,10 @@ class GeneralManager(QObject): logger.info(f"开始配置脚本运行参数:{index}", module=f"通用调度器-{self.name}") # 配置前关闭可能未正常退出的脚本进程 - System.kill_process(self.script_exe_path) + if self.mode == "自动代理": + System.kill_process(self.script_exe_path) + elif self.mode == "设置通用脚本": + System.kill_process(self.script_set_exe_path) # 预导入配置文件 if self.mode == "设置通用脚本": diff --git a/app/ui/script_manager.py b/app/ui/script_manager.py index 5e43bde..9c2d5a7 100644 --- a/app/ui/script_manager.py +++ b/app/ui/script_manager.py @@ -2458,7 +2458,7 @@ class ScriptManager(QWidget): self.card_UpdateConfigMode = ComboBoxSettingCard( icon=FluentIcon.PAGE_RIGHT, title="脚本配置文件更新时机", - content="在选定的时机自动更新配置文件", + content="在选定的时机自动更新程序保存的配置文件", texts=[ "从不", "仅任务成功后", @@ -2481,7 +2481,7 @@ class ScriptManager(QWidget): self.card_LogPathFormat = LineEditSettingCard( icon=FluentIcon.PAGE_RIGHT, title="脚本日志文件名格式", - content="若脚本日志文件名中随时间变化,请填入时间格式,留空则不启用", + content="若脚本日志文件名中随时间变化,请填入时间格式文本,留空则不启用", text="请输入脚本日志文件名格式", qconfig=self.config, configItem=self.config.Script_LogPathFormat, @@ -2489,8 +2489,8 @@ class ScriptManager(QWidget): ) self.card_LogTimeStart = SpinBoxSettingCard( icon=FluentIcon.PAGE_RIGHT, - title="脚本日志时间起始位置 - [必填]", - content="脚本日志中时间的起始位置,单位为字符", + title="脚本日志时间戳起始位置 - [必填]", + content="脚本日志中时间戳的起始位置,单位为字符", range=(1, 1024), qconfig=self.config, configItem=self.config.Script_LogTimeStart, @@ -2498,8 +2498,8 @@ class ScriptManager(QWidget): ) self.card_LogTimeEnd = SpinBoxSettingCard( icon=FluentIcon.PAGE_RIGHT, - title="脚本日志时间结束位置 - [必填]", - content="脚本日志中时间的结束位置,单位为字符", + title="脚本日志时间戳结束位置 - [必填]", + content="脚本日志中时间戳的结束位置,单位为字符", range=(1, 1024), qconfig=self.config, configItem=self.config.Script_LogTimeEnd, @@ -2507,8 +2507,8 @@ class ScriptManager(QWidget): ) self.card_LogTimeFormat = LineEditSettingCard( icon=FluentIcon.PAGE_RIGHT, - title="脚本日志时间格式 - [必填]", - content="脚本日志中时间的格式", + title="脚本日志时间戳格式 - [必填]", + content="脚本日志中时间戳的格式", text="请输入脚本日志时间格式", qconfig=self.config, configItem=self.config.Script_LogTimeFormat, diff --git a/resources/version.json b/resources/version.json index 93da179..68d819d 100644 --- a/resources/version.json +++ b/resources/version.json @@ -4,7 +4,8 @@ "4.4.1.5": { "新增功能": [ "适配 MAA 长期开放剿灭关卡", - "新增完成任务后自动复原脚本配置" + "新增完成任务后自动复原脚本配置", + "通用脚本启动附加命令添加额外的语法以适应UI可执行文件与任务可执行文件不同的情况" ], "程序优化": [ "优化调度队列配置逻辑",