feat: 新增完成任务后自动复原脚本配置

This commit is contained in:
DLmaster361
2025-07-31 17:06:08 +08:00
parent 4fc747f1c6
commit d836b58b2d
3 changed files with 52 additions and 8 deletions

View File

@@ -166,6 +166,15 @@ class MaaManager(QObject):
)
return None
# 记录 MAA 配置文件
logger.info(
f"记录 MAA 配置文件:{self.maa_set_path}",
module=f"MAA调度器-{self.name}",
)
(self.config_path / "Temp").mkdir(parents=True, exist_ok=True)
if self.maa_set_path.exists():
shutil.copy(self.maa_set_path, self.config_path / "Temp/gui.json")
# 整理用户数据,筛选需代理的用户
if "设置MAA" not in self.mode:
@@ -941,13 +950,6 @@ class MaaManager(QObject):
self.maa_process_manager.kill(if_force=True)
System.kill_process(self.maa_exe_path)
# 复原MAA配置文件
logger.info(
f"复原MAA配置文件{self.maa_set_path}",
module=f"MAA调度器-{self.name}",
)
shutil.copy(self.config_path / "Default/gui.json", self.maa_set_path)
# 更新用户数据
updated_info = {_[2]: self.data[_[2]] for _ in self.user_list}
self.update_user_info.emit(self.config_path.name, updated_info)
@@ -1000,6 +1002,15 @@ class MaaManager(QObject):
)
self.push_notification("代理结果", title, result)
# 复原 MAA 配置文件
logger.info(
f"复原 MAA 配置文件:{self.config_path / 'Temp/gui.json'}",
module=f"MAA调度器-{self.name}",
)
if (self.config_path / "Temp/gui.json").exists():
shutil.copy(self.config_path / "Temp/gui.json", self.maa_set_path)
shutil.rmtree(self.config_path / "Temp")
self.agree_bilibili(False)
self.log_monitor.deleteLater()
self.log_monitor_timer.deleteLater()

View File

@@ -195,6 +195,22 @@ class GeneralManager(QObject):
self.configure()
# 记录配置文件
logger.info(
f"记录通用脚本配置文件:{self.script_config_path}",
module=f"通用调度器-{self.name}",
)
(self.config_path / "Temp").mkdir(parents=True, exist_ok=True)
if self.set["Script"]["ConfigPathMode"] == "文件夹":
if self.script_config_path.exists():
shutil.copytree(
self.script_config_path,
self.config_path / "Temp",
dirs_exist_ok=True,
)
elif self.script_config_path.exists():
shutil.copy(self.script_config_path, self.config_path / "Temp/config.temp")
# 整理用户数据,筛选需代理的用户
if self.mode != "设置通用脚本":
@@ -648,6 +664,22 @@ class GeneralManager(QObject):
)
self.push_notification("代理结果", title, result)
# 复原通用脚本配置文件
logger.info(
f"复原通用脚本配置文件:{self.config_path / 'Temp'}",
module=f"通用调度器-{self.name}",
)
if self.set["Script"]["ConfigPathMode"] == "文件夹":
if (self.config_path / "Temp").exists():
shutil.copytree(
self.config_path / "Temp",
self.script_config_path,
dirs_exist_ok=True,
)
elif (self.config_path / "Temp/config.temp").exists():
shutil.copy(self.config_path / "Temp/config.temp", self.script_config_path)
shutil.rmtree(self.config_path / "Temp")
self.log_monitor.deleteLater()
self.log_monitor_timer.deleteLater()
self.accomplish.emit({"Time": begin_time, "History": result_text})

View File

@@ -3,7 +3,8 @@
"version_info": {
"4.4.1.5": {
"新增功能": [
"适配 MAA 长期开放剿灭关卡"
"适配 MAA 长期开放剿灭关卡",
"新增完成任务后自动复原脚本配置"
],
"程序优化": [
"优化调度队列配置逻辑",