feat(core): 添加强制关闭ADB与模拟器等增强任务项
This commit is contained in:
@@ -926,6 +926,12 @@ class MaaConfig(QConfig):
|
||||
"ExitEmulator",
|
||||
OptionsValidator(["NoAction", "ExitGame", "ExitEmulator"]),
|
||||
)
|
||||
RunSet_EnhanceTask = OptionsConfigItem(
|
||||
"RunSet",
|
||||
"EnhanceTask",
|
||||
"None",
|
||||
OptionsValidator(["None", "KillADB", "KillEmulator", "KillADB&Emulator"]),
|
||||
)
|
||||
RunSet_ProxyTimesLimit = RangeConfigItem(
|
||||
"RunSet", "ProxyTimesLimit", 0, RangeValidator(0, 1024)
|
||||
)
|
||||
|
||||
@@ -237,23 +237,34 @@ class MaaManager(QObject):
|
||||
continue
|
||||
|
||||
# 配置MAA
|
||||
self.set_maa(mode_book[j], user[2])
|
||||
set = self.set_maa(mode_book[j], user[2])
|
||||
# 记录当前时间
|
||||
start_time = datetime.now()
|
||||
|
||||
# 记录模拟器与ADB路径
|
||||
self.emulator_path = Path(
|
||||
set["Configurations"]["Default"]["Start.EmulatorPath"]
|
||||
)
|
||||
self.ADB_path = Path(
|
||||
set["Configurations"]["Default"]["Connect.AdbPath"]
|
||||
)
|
||||
self.if_kill_emulator = bool(
|
||||
set["Configurations"]["Default"]["MainFunction.PostActions"]
|
||||
== "12"
|
||||
)
|
||||
# 添加静默进程标记
|
||||
Config.silence_list.append(self.emulator_path)
|
||||
|
||||
# 增强任务:任务开始前强杀ADB
|
||||
if "ADB" in self.set["RunSet"]["EnhanceTask"]:
|
||||
System.kill_process(self.ADB_path)
|
||||
|
||||
# 创建MAA任务
|
||||
maa = subprocess.Popen(
|
||||
[self.maa_exe_path],
|
||||
shell=True,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||
)
|
||||
# 添加静默进程标记
|
||||
with self.maa_set_path.open(mode="r", encoding="utf-8") as f:
|
||||
set = json.load(f)
|
||||
self.emulator_path = Path(
|
||||
set["Configurations"]["Default"]["Start.EmulatorPath"]
|
||||
)
|
||||
Config.silence_list.append(self.emulator_path)
|
||||
|
||||
# 监测MAA运行状态
|
||||
self.start_monitor(start_time, mode_book[j])
|
||||
|
||||
@@ -280,6 +291,8 @@ class MaaManager(QObject):
|
||||
)
|
||||
# 无命令行中止MAA与其子程序
|
||||
System.kill_process(self.maa_exe_path)
|
||||
if "Emulator" in self.set["RunSet"]["EnhanceTask"]:
|
||||
System.kill_process(self.emulator_path)
|
||||
self.if_open_emulator = True
|
||||
# 推送异常通知
|
||||
Notify.push_plyer(
|
||||
@@ -296,6 +309,15 @@ class MaaManager(QObject):
|
||||
# 移除静默进程标记
|
||||
Config.silence_list.remove(self.emulator_path)
|
||||
|
||||
# 增强任务:任务结束后强杀ADB和模拟器
|
||||
if "ADB" in self.set["RunSet"]["EnhanceTask"]:
|
||||
System.kill_process(self.ADB_path)
|
||||
if (
|
||||
self.if_kill_emulator
|
||||
and "Emulator" in self.set["RunSet"]["EnhanceTask"]
|
||||
):
|
||||
System.kill_process(self.emulator_path)
|
||||
|
||||
# 保存运行日志以及统计信息
|
||||
if_six_star = Config.save_maa_log(
|
||||
Config.app_path
|
||||
@@ -698,7 +720,7 @@ class MaaManager(QObject):
|
||||
self.log_monitor_timer.stop()
|
||||
self.monitor_loop.quit()
|
||||
|
||||
def set_maa(self, mode, index):
|
||||
def set_maa(self, mode, index) -> dict:
|
||||
"""配置MAA运行参数"""
|
||||
logger.info(f"{self.name} | 配置MAA运行参数: {mode}/{index}")
|
||||
|
||||
@@ -1132,7 +1154,7 @@ class MaaManager(QObject):
|
||||
with self.maa_set_path.open(mode="w", encoding="utf-8") as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||
|
||||
return True
|
||||
return data
|
||||
|
||||
def agree_bilibili(self, if_agree):
|
||||
"""向MAA写入Bilibili协议相关任务"""
|
||||
@@ -1165,15 +1187,6 @@ class MaaManager(QObject):
|
||||
with self.maa_tasks_path.open(mode="w", encoding="utf-8") as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||
|
||||
def get_emulator_path(self):
|
||||
"""获取模拟器路径"""
|
||||
|
||||
# 读取配置文件
|
||||
with self.maa_set_path.open(mode="r", encoding="utf-8") as f:
|
||||
set = json.load(f)
|
||||
# 获取模拟器路径
|
||||
return Path(set["Configurations"]["Default"]["Start.EmulatorPath"])
|
||||
|
||||
def server_date(self):
|
||||
"""获取当前的服务器日期"""
|
||||
|
||||
|
||||
@@ -657,6 +657,18 @@ class MaaSettingBox(QWidget):
|
||||
content="简洁用户列表下相邻两个任务间的切换方式",
|
||||
texts=["直接切换账号", "重启明日方舟", "重启模拟器"],
|
||||
)
|
||||
self.card_EnhanceTask = ComboBoxSettingCard(
|
||||
configItem=Config.maa_config.RunSet_EnhanceTask,
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="自动代理增效任务",
|
||||
content="自动代理时的额外操作,此操作无法区分多开,可能会干扰其他任务,也可能关闭您正在使用的模拟器",
|
||||
texts=[
|
||||
"禁用",
|
||||
"强制关闭ADB",
|
||||
"强制关闭所有模拟器",
|
||||
"强制关闭ADB和所有模拟器",
|
||||
],
|
||||
)
|
||||
self.ProxyTimesLimit = SpinBoxSettingCard(
|
||||
(0, 1024),
|
||||
FluentIcon.PAGE_RIGHT,
|
||||
@@ -689,6 +701,7 @@ class MaaSettingBox(QWidget):
|
||||
widget = QWidget()
|
||||
Layout = QVBoxLayout(widget)
|
||||
Layout.addWidget(self.card_TaskTransitionMethod)
|
||||
Layout.addWidget(self.card_EnhanceTask)
|
||||
Layout.addWidget(self.ProxyTimesLimit)
|
||||
Layout.addWidget(self.AnnihilationTimeLimit)
|
||||
Layout.addWidget(self.RoutineTimeLimit)
|
||||
|
||||
@@ -44,4 +44,5 @@ G"Start.MinimizeDirectly": "True" #启动MAA后直接最小化
|
||||
"Start.OpenEmulatorAfterLaunch": "True" #启动MAA后自动开启模拟器
|
||||
G"GUI.UseTray": "True" #显示托盘图标
|
||||
G"GUI.MinimizeToTray": "False" #最小化时隐藏至托盘
|
||||
"Start.EmulatorPath" #模拟器路径
|
||||
"Start.EmulatorPath" #模拟器路径
|
||||
"Connect.AdbPath" #ADB路径
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"main_version": "4.2.5.3",
|
||||
"main_version": "4.2.5.4",
|
||||
"updater_version": "1.2.0.0",
|
||||
"announcement": "\n## 新增功能\n- 屏蔽MuMu模拟器开屏广告功能上线\n- 更新器支持多线程下载\n## 修复BUG\n- 修复统计信息HTML模板公招匹配错误\n- 修复密码显示按钮动画异常\n## 程序优化\n- 关机等电源操作添加100s倒计时\n- 人工排查弹窗方法优化\n- 人工排查时自动屏蔽静默操作",
|
||||
"announcement": "\n## 新增功能\n- 屏蔽MuMu模拟器开屏广告功能上线\n- 更新器支持多线程下载\n- 添加强制关闭ADB与模拟器等增强任务项\n## 修复BUG\n- 修复统计信息HTML模板公招匹配错误\n- 修复密码显示按钮动画异常\n## 程序优化\n- 关机等电源操作添加100s倒计时\n- 人工排查弹窗方法优化\n- 人工排查时自动屏蔽静默操作",
|
||||
"proxy_list": [
|
||||
"",
|
||||
"https://gitproxy.click/",
|
||||
|
||||
Reference in New Issue
Block a user