Merge branch 'generic_dev' into dev

This commit is contained in:
DLmaster361
2025-07-10 17:35:22 +08:00
34 changed files with 194 additions and 93 deletions

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@ config/
data/
debug/
history/
script/
resources/notice.json
resources/theme_image.json
resources/images/Home/BannerTheme.jpg

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA主程序包
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA核心组件包
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA配置管理
v4.3
v4.4
作者DLmaster_361
"""
@@ -601,14 +601,21 @@ class GeneralConfig(LQConfig):
)
self.Script_Arguments = ConfigItem("Script", "Arguments", "")
self.Script_ConfigPath = ConfigItem(
"Script", "ConfigPath", ".", FolderValidator()
"Script", "ConfigPath", ".", FileValidator()
)
self.Script_ConfigPathMode = OptionsConfigItem(
"Script",
"ConfigPathMode",
"所有文件 (*)",
OptionsValidator(["所有文件 (*)", "文件夹"]),
)
self.Script_LogPath = ConfigItem("Script", "LogPath", ".", FileValidator())
self.Script_LogPathFormat = ConfigItem("Script", "LogPathFormat", "%Y-%m-%d")
self.Script_LogTimeStart = ConfigItem(
"Script", "LogTimeStart", 0, RangeValidator(0, 1024)
"Script", "LogTimeStart", 1, RangeValidator(1, 1024)
)
self.Script_LogTimeEnd = ConfigItem(
"Script", "LogTimeEnd", 0, RangeValidator(0, 1024)
"Script", "LogTimeEnd", 1, RangeValidator(1, 1024)
)
self.Script_LogTimeFormat = ConfigItem(
"Script", "LogTimeFormat", "%Y-%m-%d %H:%M:%S"
@@ -616,7 +623,7 @@ class GeneralConfig(LQConfig):
self.Script_SuccessLog = ConfigItem("Script", "SuccessLog", "")
self.Script_ErrorLog = ConfigItem("Script", "ErrorLog", "")
self.Game_Enabled = ConfigItem("Game", "Enabled", True, BoolValidator())
self.Game_Enabled = ConfigItem("Game", "Enabled", False, BoolValidator())
self.Game_Style = OptionsConfigItem(
"Game", "Style", "Emulator", OptionsValidator(["Emulator", "Client"])
)
@@ -695,7 +702,7 @@ class GeneralSubConfig(LQConfig):
class AppConfig(GlobalConfig):
VERSION = "4.4.0.1"
VERSION = "4.4.0.2"
gameid_refreshed = Signal()
PASSWORD_refreshed = Signal()

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA信息通知栏
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA网络请求线程
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA音效播放器
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA业务调度器
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA主业务定时器
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
MAA功能组件
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA模组包
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
通用功能组件
v4.3
v4.4
作者DLmaster_361
"""
@@ -118,7 +118,7 @@ class GeneralManager(QObject):
Path(self.set["Script"]["RootPath"]).exists()
and Path(self.set["Script"]["ScriptPath"]).exists()
and Path(self.set["Script"]["ConfigPath"]).exists()
and Path(self.set["Script"]["LogPath"]).exists()
and Path(self.set["Script"]["LogPath"]).parent.exists()
and self.set["Script"]["LogTimeFormat"]
and self.set["Script"]["ErrorLog"]
) or (
@@ -137,16 +137,24 @@ class GeneralManager(QObject):
self.script_root_path = Path(self.set["Script"]["RootPath"])
self.script_exe_path = Path(self.set["Script"]["ScriptPath"])
self.script_config_path = Path(self.set["Script"]["ConfigPath"])
self.script_log_path = Path(self.set["Script"]["LogPath"])
self.script_log_path = (
Path(self.set["Script"]["LogPath"]).with_stem(
datetime.now().strftime(self.set["Script"]["LogPathFormat"])
)
if self.set["Script"]["LogPathFormat"]
else Path(self.set["Script"]["LogPath"])
)
if not self.script_log_path.exists():
self.script_log_path.parent.mkdir(parents=True, exist_ok=True)
self.script_log_path.touch(exist_ok=True)
self.game_path = Path(self.set["Game"]["Path"])
self.log_time_range = [
self.set["Script"]["LogTimeStart"],
self.set["Script"]["LogTimeStart"] - 1,
self.set["Script"]["LogTimeEnd"],
]
self.success_log = [
_.strip() for _ in self.set["Script"]["SuccessLog"].split("|")
]
print(f"Success Log: {self.success_log}")
self.error_log = [_.strip() for _ in self.set["Script"]["ErrorLog"].split("|")]
def run(self):
@@ -431,9 +439,14 @@ class GeneralManager(QObject):
self.start_monitor(start_time)
self.sub_config_path.mkdir(parents=True, exist_ok=True)
shutil.copytree(
self.script_config_path, self.sub_config_path, dirs_exist_ok=True
)
if self.set["Script"]["ConfigPathMode"] == "文件夹":
shutil.copytree(
self.script_config_path,
self.sub_config_path,
dirs_exist_ok=True,
)
else:
shutil.copy(self.script_config_path, self.sub_config_path)
except Exception as e:
logger.error(f"{self.name} | 启动通用脚本时出现异常:{e}")
@@ -690,15 +703,31 @@ class GeneralManager(QObject):
# 预导入配置文件
if self.mode == "设置通用脚本":
if self.sub_config_path.exists():
shutil.copytree(
self.sub_config_path, self.script_config_path, dirs_exist_ok=True
)
if self.set["Script"]["ConfigPathMode"] == "文件夹":
shutil.copytree(
self.sub_config_path,
self.script_config_path,
dirs_exist_ok=True,
)
elif (self.sub_config_path / self.script_config_path.name).exists():
shutil.copy(
self.sub_config_path / self.script_config_path.name,
self.script_config_path,
)
else:
shutil.copytree(
self.data[index]["Path"] / "ConfigFiles",
self.script_config_path,
dirs_exist_ok=True,
)
if self.set["Script"]["ConfigPathMode"] == "文件夹":
shutil.copytree(
self.data[index]["Path"] / "ConfigFiles",
self.script_config_path,
dirs_exist_ok=True,
)
else:
shutil.copy(
self.data[index]["Path"]
/ "ConfigFiles"
/ self.script_config_path.name,
self.script_config_path,
)
def execute_script_task(self, script_path: Path, task_name: str) -> bool:
"""执行脚本任务并等待结束"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA服务包
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA通知服务
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA安全服务
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -28,7 +28,7 @@
"""
AUTO_MAA
AUTO_MAA森空岛服务
v4.3
v4.4
作者DLmaster_361、ClozyA
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA系统服务
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -27,7 +27,7 @@
"""
AUTO_MAA
AUTO_MAA组件
v4.3
v4.4
作者DLmaster_361
"""
@@ -577,7 +577,7 @@ class PathSettingCard(PushSettingCard):
self,
icon: Union[str, QIcon, FluentIconBase],
title: str,
mode: str,
mode: Union[str, OptionsConfigItem],
text: str,
qconfig: QConfig,
configItem: ConfigItem,
@@ -590,6 +590,18 @@ class PathSettingCard(PushSettingCard):
self.qconfig = qconfig
self.configItem = configItem
if isinstance(mode, OptionsConfigItem):
self.ComboBox = ComboBox(self)
self.hBoxLayout.insertWidget(5, self.ComboBox, 0, Qt.AlignRight)
for option in mode.options:
self.ComboBox.addItem(option, userData=option)
self.ComboBox.setCurrentText(self.qconfig.get(mode))
self.ComboBox.currentIndexChanged.connect(self._onCurrentIndexChanged)
mode.valueChanged.connect(self.setValue)
self.setContent(self.qconfig.get(self.configItem))
self.clicked.connect(self.ChoosePath)
@@ -602,7 +614,7 @@ class PathSettingCard(PushSettingCard):
old_path = Path(self.qconfig.get(self.configItem))
if self.mode == "文件夹":
if self.get_mode() == "文件夹":
folder = QFileDialog.getExistingDirectory(
self, "选择文件夹", self.qconfig.get(self.configItem)
@@ -614,7 +626,7 @@ class PathSettingCard(PushSettingCard):
else:
file_path, _ = QFileDialog.getOpenFileName(
self, "打开文件", self.qconfig.get(self.configItem), self.mode
self, "打开文件", self.qconfig.get(self.configItem), self.get_mode()
)
if file_path:
file_path = self.analysis_lnk(file_path)
@@ -635,6 +647,21 @@ class PathSettingCard(PushSettingCard):
else:
return lnk_path
def get_mode(self) -> str:
"""获取当前模式"""
if isinstance(self.mode, OptionsConfigItem):
return self.qconfig.get(self.mode)
return self.mode
def _onCurrentIndexChanged(self, index: int):
self.qconfig.set(self.mode, self.ComboBox.itemData(index))
def setValue(self, value):
self.ComboBox.setCurrentText(value)
self.qconfig.set(self.mode, value)
class PushAndSwitchButtonSettingCard(SettingCard):
"""Setting card with push & switch button"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA图形化界面包
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA调度中枢界面
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA更新器
v4.3
v4.4
作者DLmaster_361
"""
@@ -47,6 +47,8 @@ from PySide6.QtCore import QThread, Signal, QTimer, QEventLoop
from typing import List, Dict, Union
from app.services import System
def version_text(version_numb: list) -> str:
"""将版本号列表转为可读的文本信息"""
@@ -94,7 +96,15 @@ class DownloadProcess(QThread):
if self.download_path.exists():
self.download_path.unlink()
headers = {"Range": f"bytes={self.start_byte}-{self.end_byte}"}
logger.info(
f"开始下载:{self.url},范围:{self.start_byte}-{self.end_byte},存储地址:{self.download_path}"
)
headers = (
{"Range": f"bytes={self.start_byte}-{self.end_byte}"}
if not (self.start_byte == -1 or self.end_byte == -1)
else None
)
while not self.isInterruptionRequested() and self.check_times != 0:
@@ -106,14 +116,20 @@ class DownloadProcess(QThread):
self.url, headers=headers, timeout=10, stream=True
)
if response.status_code != 206:
if response.status_code not in [200, 206]:
if self.check_times != -1:
self.check_times -= 1
logger.error(
f"连接失败:{self.url},状态码:{response.status_code},剩余重试次数:{self.check_times}"
)
time.sleep(1)
continue
logger.info(f"连接成功:{self.url},状态码:{response.status_code}")
downloaded_size = 0
with self.download_path.open(mode="wb") as f:
@@ -132,10 +148,14 @@ class DownloadProcess(QThread):
if self.download_path.exists():
self.download_path.unlink()
self.accomplish.emit(0)
logger.info(f"下载中止:{self.url}")
else:
self.accomplish.emit(time.time() - start_time)
logger.success(
f"下载完成:{self.url},实际下载大小:{downloaded_size} 字节,耗时:{time.time() - start_time:.2f}"
)
break
@@ -143,6 +163,10 @@ class DownloadProcess(QThread):
if self.check_times != -1:
self.check_times -= 1
logger.exception(
f"下载出错:{self.url},错误信息:{e},剩余重试次数:{self.check_times}"
)
time.sleep(1)
else:
@@ -150,6 +174,7 @@ class DownloadProcess(QThread):
if self.download_path.exists():
self.download_path.unlink()
self.accomplish.emit(0)
logger.error(f"下载失败:{self.url}")
class ZipExtractProcess(QThread):
@@ -172,6 +197,8 @@ class ZipExtractProcess(QThread):
try:
logger.info(f"开始解压:{self.download_path}{self.app_path}")
while True:
if self.isInterruptionRequested():
@@ -181,13 +208,15 @@ class ZipExtractProcess(QThread):
with zipfile.ZipFile(self.download_path, "r") as zip_ref:
zip_ref.extractall(self.app_path)
self.accomplish.emit()
logger.success(f"解压完成:{self.download_path}{self.app_path}")
break
except PermissionError:
if self.name == "AUTO_MAA":
self.info.emit(f"解压出错AUTO_MAA正在运行正在尝试将其关闭")
self.kill_process(self.app_path / "AUTO_MAA.exe")
System.kill_process(self.app_path / "AUTO_MAA.exe")
else:
self.info.emit(f"解压出错:{self.name}正在运行,正在等待其关闭")
logger.warning(f"解压出错:{self.name}正在运行,正在等待其关闭")
time.sleep(1)
except Exception as e:
@@ -195,32 +224,9 @@ class ZipExtractProcess(QThread):
e = str(e)
e = "\n".join([e[_ : _ + 75] for _ in range(0, len(e), 75)])
self.info.emit(f"解压更新时出错:\n{e}")
logger.exception(f"解压更新时出错:{e}")
return None
def kill_process(self, path: Path) -> None:
"""根据路径中止进程"""
for pid in self.search_pids(path):
killprocess = subprocess.Popen(
f"taskkill /F /PID {pid}",
shell=True,
creationflags=subprocess.CREATE_NO_WINDOW,
)
killprocess.wait()
def search_pids(self, path: Path) -> list:
"""根据路径查找进程PID"""
pids = []
for proc in psutil.process_iter(["pid", "exe"]):
try:
if proc.info["exe"] and proc.info["exe"].lower() == str(path).lower():
pids.append(proc.info["pid"])
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
# 进程可能在此期间已结束或无法访问,忽略这些异常
pass
return pids
class DownloadManager(QDialog):
"""下载管理器"""
@@ -346,6 +352,8 @@ class DownloadManager(QDialog):
url_dict = self.get_download_url("测速")
self.test_speed_result: Dict[str, float] = {}
logger.info(f"测速链接:{url_dict}")
for name, url in url_dict.items():
if self.isInterruptionRequested:
@@ -427,6 +435,7 @@ class DownloadManager(QDialog):
# 保存测速结果
self.config["speed_result"] = self.test_speed_result
logger.info(f"测速结果:{self.test_speed_result}")
self.update_info("测速完成!")
self.speed_test_accomplish.emit()
@@ -465,8 +474,8 @@ class DownloadManager(QDialog):
# 创建下载子线程
self.download_process_dict[f"part{i}"] = DownloadProcess(
url,
start_byte,
end_byte,
-1 if self.config["mode"] == "MirrorChyan" else start_byte,
-1 if self.config["mode"] == "MirrorChyan" else end_byte,
self.download_path.with_suffix(f".part{i}"),
1 if self.config["mode"] == "MirrorChyan" else -1,
)
@@ -525,6 +534,9 @@ class DownloadManager(QDialog):
return None
# 合并下载的分段文件
logger.info(
f"所有分段下载完成:{self.name},开始合并分段文件到 {self.download_path}"
)
with self.download_path.open(mode="wb") as outfile:
for i in range(self.config["thread_numb"]):
with self.download_path.with_suffix(f".part{i}").open(
@@ -533,6 +545,10 @@ class DownloadManager(QDialog):
outfile.write(infile.read())
self.download_path.with_suffix(f".part{i}").unlink()
logger.success(
f"合并完成:{self.name},下载文件大小:{self.download_path.stat().st_size} 字节"
)
self.update_info("正在解压更新文件")
self.update_progress(0, 0, 0)
@@ -583,6 +599,9 @@ class DownloadManager(QDialog):
self.progress_2.setValue(current)
def requestInterruption(self) -> None:
"""请求中断下载任务"""
logger.info("收到下载任务中止请求")
self.isInterruptionRequested = True

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA历史记录界面
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA主界面
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA主界面
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA脚本管理界面
v4.3
v4.4
作者DLmaster_361
"""
@@ -2312,27 +2312,36 @@ class MemberManager(QWidget):
)
self.card_ConfigPath = PathSettingCard(
icon=FluentIcon.FOLDER,
title="脚本配置文件目录 - [必填]",
mode="文件夹",
text="选择文件夹",
title="脚本配置文件路径 - [必填]",
mode=self.config.Script_ConfigPathMode,
text="选择路径",
qconfig=self.config,
configItem=self.config.Script_ConfigPath,
parent=self,
)
self.card_LogPath = PathSettingCard(
icon=FluentIcon.FOLDER,
title="脚本日志文件目录 - [必填]",
title="脚本日志文件路径 - [必填]",
mode="所有文件 (*)",
text="选择文件",
qconfig=self.config,
configItem=self.config.Script_LogPath,
parent=self,
)
self.card_LogPathFormat = LineEditSettingCard(
icon=FluentIcon.PAGE_RIGHT,
title="脚本日志文件名格式",
content="若脚本日志文件名中随时间变化,请填入时间格式,留空则不启用",
text="请输入脚本日志文件名格式",
qconfig=self.config,
configItem=self.config.Script_LogPathFormat,
parent=self,
)
self.card_LogTimeStart = SpinBoxSettingCard(
icon=FluentIcon.PAGE_RIGHT,
title="脚本日志时间起始位置 - [必填]",
content="脚本日志中时间的起始位置,单位为字符",
range=(0, 1024),
range=(1, 1024),
qconfig=self.config,
configItem=self.config.Script_LogTimeStart,
parent=self,
@@ -2341,7 +2350,7 @@ class MemberManager(QWidget):
icon=FluentIcon.PAGE_RIGHT,
title="脚本日志时间结束位置 - [必填]",
content="脚本日志中时间的结束位置,单位为字符",
range=(0, 1024),
range=(1, 1024),
qconfig=self.config,
configItem=self.config.Script_LogTimeEnd,
parent=self,
@@ -2402,6 +2411,7 @@ class MemberManager(QWidget):
Layout.addWidget(self.card_Arguments)
Layout.addWidget(self.card_ConfigPath)
Layout.addWidget(self.card_LogPath)
Layout.addWidget(self.card_LogPathFormat)
Layout.addLayout(h_layout)
Layout.addWidget(self.card_LogTimeFormat)
Layout.addWidget(self.card_SuccessLog)
@@ -3066,7 +3076,7 @@ class MemberManager(QWidget):
self.card_ScriptBeforeTask = PathSettingCard(
icon=FluentIcon.FOLDER,
title="脚本前置任务",
mode="脚本文件 (*.py *.bat *.exe)",
mode="脚本文件 (*.py *.bat *.cmd *.exe)",
text="选择脚本文件",
qconfig=self.config,
configItem=self.config.Info_ScriptBeforeTask,
@@ -3081,7 +3091,7 @@ class MemberManager(QWidget):
self.card_ScriptAfterTask = PathSettingCard(
icon=FluentIcon.FOLDER,
title="脚本后置任务",
mode="脚本文件 (*.py *.bat *.exe)",
mode="脚本文件 (*.py *.bat *.cmd *.exe)",
text="选择脚本文件",
qconfig=self.config,
configItem=self.config.Info_ScriptAfterTask,

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA计划管理界面
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA调度队列界面
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA设置界面
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA图像组件
v4.3
v4.4
作者ClozyA
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA进程管理组件
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA工具包
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA打包程序
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -21,7 +21,7 @@
"""
AUTO_MAA
AUTO_MAA主程序
v4.3
v4.4
作者DLmaster_361
"""

View File

@@ -1,6 +1,14 @@
{
"main_version": "4.4.0.1",
"main_version": "4.4.0.2",
"version_info": {
"4.4.0.2": {
"新增功能": [
"进一步适配三月七相关配置项"
],
"修复BUG": [
"适配 Mirror 酱 平台下载策略调整"
]
},
"4.4.0.1": {
"新增功能": [
"初步完成通用调度模块"