From 24b93cfcadcf0579088b1aa05c6fb8897bfc679c Mon Sep 17 00:00:00 2001 From: DLmaster361 Date: Sun, 4 May 2025 23:43:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8B=E8=BD=BD=E5=99=A8=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=B0=83=E7=94=A8Mirror=E9=85=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/config.py | 2 +- app/ui/member_manager.py | 78 +++++++++++++++++++++++++++++++++------- app/ui/setting.py | 75 ++++++++++++++++++++------------------ app/utils/downloader.py | 24 +++++++++---- resources/version.json | 33 +++++------------ 5 files changed, 132 insertions(+), 80 deletions(-) diff --git a/app/core/config.py b/app/core/config.py index 0729d4e..bb6730e 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -617,7 +617,7 @@ class MaaUserConfig(QConfig): class AppConfig(GlobalConfig): - VERSION = "4.3.6.2" + VERSION = "4.3.6.3" gameid_refreshed = Signal() PASSWORD_refreshed = Signal() diff --git a/app/ui/member_manager.py b/app/ui/member_manager.py index 467345d..4d40ab2 100644 --- a/app/ui/member_manager.py +++ b/app/ui/member_manager.py @@ -35,6 +35,7 @@ from PySide6.QtWidgets import ( QTableWidgetItem, QHeaderView, ) +from PySide6.QtGui import QIcon from qfluentwidgets import ( Action, Pivot, @@ -338,22 +339,62 @@ class MemberManager(QWidget): # 从mirrorc服务器获取最新版本信息 Network.set_info( mode="get", - url="https://mirrorchyan.com/api/resources/MAA/latest?user_agent=AutoMaaGui&os=win&arch=x64&channel=stable", + url=f"https://mirrorchyan.com/api/resources/MAA/latest?user_agent=AutoMaaGui&cdk={Crypto.win_decryptor(Config.get(Config.update_MirrorChyanCDK))}&os=win&arch=x64&channel=stable", ) Network.start() Network.loop.exec() if Network.stutus_code == 200: maa_info = Network.response_json else: - choice = MessageBox( - "错误", - f"获取版本信息时出错:\n{Network.error_message}", - self.window(), + + if Network.response_json: + + maa_info = Network.response_json + + if maa_info["code"] != 0: + + logger.error(f"获取版本信息时出错:{maa_info["msg"]}") + + error_remark_dict = { + 1001: "获取版本信息的URL参数不正确", + 7001: "填入的 CDK 已过期", + 7002: "填入的 CDK 错误", + 7003: "填入的 CDK 今日下载次数已达上限", + 7004: "填入的 CDK 类型和待下载的资源不匹配", + 7005: "填入的 CDK 已被封禁", + 8001: "对应架构和系统下的资源不存在", + 8002: "错误的系统参数", + 8003: "错误的架构参数", + 8004: "错误的更新通道参数", + 1: maa_info["msg"], + } + + if maa_info["code"] in error_remark_dict: + MainInfoBar.push_info_bar( + "error", + "获取版本信息时出错", + error_remark_dict[maa_info["code"]], + -1, + ) + else: + MainInfoBar.push_info_bar( + "error", + "获取版本信息时出错", + "意料之外的错误,请及时联系项目组以获取来自 Mirror 酱的技术支持", + -1, + ) + + return None + + logger.warning(f"获取版本信息时出错:{Network.error_message}") + MainInfoBar.push_info_bar( + "warning", + "获取版本信息时出错", + f"网络错误:{Network.stutus_code}", + 5000, ) - choice.cancelButton.hide() - choice.buttonLayout.insertStretch(1) - if choice.exec(): - return None + return None + maa_version = list( map( int, @@ -369,10 +410,21 @@ class MemberManager(QWidget): Path(folder), "MAA", maa_version, - { - "mode": "Proxy", - "thread_numb": Config.get(Config.update_ThreadNumb), - }, + ( + { + "mode": "MirrorChyan", + "thread_numb": 1, + "url": maa_info["data"]["url"], + } + if "url" in maa_info["data"] + else { + "mode": "Proxy", + "thread_numb": Config.get(Config.update_ThreadNumb), + } + ), + ) + self.downloader.setWindowIcon( + QIcon(str(Config.app_path / "resources/icons/AUTO_MAA_Updater.ico")) ) self.downloader.show() self.downloader.run() diff --git a/app/ui/setting.py b/app/ui/setting.py index fe94877..a3b09a0 100644 --- a/app/ui/setting.py +++ b/app/ui/setting.py @@ -277,6 +277,46 @@ class Setting(QWidget): Network.response_json ) else: + + if Network.response_json: + + version_info = Network.response_json + + if version_info["code"] != 0: + + logger.error(f"获取版本信息时出错:{version_info["msg"]}") + + error_remark_dict = { + 1001: "获取版本信息的URL参数不正确", + 7001: "填入的 CDK 已过期", + 7002: "填入的 CDK 错误", + 7003: "填入的 CDK 今日下载次数已达上限", + 7004: "填入的 CDK 类型和待下载的资源不匹配", + 7005: "填入的 CDK 已被封禁", + 8001: "对应架构和系统下的资源不存在", + 8002: "错误的系统参数", + 8003: "错误的架构参数", + 8004: "错误的更新通道参数", + 1: version_info["msg"], + } + + if version_info["code"] in error_remark_dict: + MainInfoBar.push_info_bar( + "error", + "获取版本信息时出错", + error_remark_dict[version_info["code"]], + -1, + ) + else: + MainInfoBar.push_info_bar( + "error", + "获取版本信息时出错", + "意料之外的错误,请及时联系项目组以获取来自 Mirror 酱的技术支持", + -1, + ) + + return None + logger.warning(f"获取版本信息时出错:{Network.error_message}") MainInfoBar.push_info_bar( "warning", @@ -286,41 +326,6 @@ class Setting(QWidget): ) return None - if version_info["code"] != 0: - - logger.error(f"获取版本信息时出错:{version_info["msg"]}") - - error_remark_dict = { - 1001: "获取版本信息的URL参数不正确", - 7001: "填入的 CDK 已过期", - 7002: "填入的 CDK 错误", - 7003: "填入的 CDK 今日下载次数已达上限", - 7004: "填入的 CDK 类型和待下载的资源不匹配", - 7005: "填入的 CDK 已被封禁", - 8001: "对应架构和系统下的资源不存在", - 8002: "错误的系统参数", - 8003: "错误的架构参数", - 8004: "错误的更新通道参数", - 1: version_info["msg"], - } - - if version_info["code"] in error_remark_dict: - MainInfoBar.push_info_bar( - "error", - "获取版本信息时出错", - error_remark_dict[version_info["code"]], - -1, - ) - else: - MainInfoBar.push_info_bar( - "error", - "获取版本信息时出错", - "意料之外的错误,请及时联系项目组以获取来自 Mirror 酱的技术支持", - -1, - ) - - return None - remote_version = list( map( int, diff --git a/app/utils/downloader.py b/app/utils/downloader.py index 769eb5e..230a0a9 100644 --- a/app/utils/downloader.py +++ b/app/utils/downloader.py @@ -301,7 +301,21 @@ class DownloadManager(QDialog): elif mode == "下载": if self.name == "MAA": - return f"https://jp-download.fearr.xyz/MAA/MAA-{version_text(self.version)}-win-x64.zip" + + if self.config["mode"] == "Proxy": + + return f"https://jp-download.fearr.xyz/MAA/MAA-{version_text(self.version)}-win-x64.zip" + + elif self.config["mode"] == "MirrorChyan": + + with requests.get( + self.config["url"], + allow_redirects=True, + timeout=10, + stream=True, + ) as response: + if response.status_code == 200: + return response.url if self.name == "AUTO_MAA": @@ -325,6 +339,7 @@ class DownloadManager(QDialog): return f"{selected_url}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.version)}/AUTO_MAA_{version_text(self.version)}.zip" elif self.config["mode"] == "MirrorChyan": + with requests.get( self.config["url"], allow_redirects=True, @@ -746,10 +761,5 @@ if __name__ == "__main__": if version.parse(version_text(remote_version)) > version.parse( version_text(current_version) ): - app = AUTO_MAA_Downloader( - app_path, - "AUTO_MAA", - remote_version, - download_config, - ) + app = AUTO_MAA_Downloader(app_path, "AUTO_MAA", remote_version, download_config) sys.exit(app.exec()) diff --git a/resources/version.json b/resources/version.json index 4a5bab0..520c062 100644 --- a/resources/version.json +++ b/resources/version.json @@ -1,8 +1,16 @@ { - "main_version": "4.3.6.2", + "main_version": "4.3.6.3", "updater_version": "1.0.0.0", "announcement": "\n## 新增功能\n- 屏蔽MuMu模拟器开屏广告功能上线\n- 更新器支持多线程下载\n- 添加强制关闭ADB与模拟器等增强任务项\n## 修复BUG\n- 修复统计信息HTML模板公招匹配错误\n- 修复密码显示按钮动画异常\n- 修复`检测到MAA未能实际执行任务`报错被异常屏蔽\n- 修复MAA超时判定异常失效\n## 程序优化\n- 关机等电源操作添加100s倒计时\n- 人工排查弹窗方法优化\n- 人工排查时自动屏蔽静默操作\n- 公告样式优化", "version_info": { + "4.3.6.3": { + "新增功能": [ + "下载器支持调用Mirror酱" + ], + "修复BUG": [ + "修复Mirror酱更新检查报错不显示详细信息的问题" + ] + }, "4.3.6.2": { "新增功能": [ "新增`无人值守模式`" @@ -22,29 +30,6 @@ "新增功能": [ "单次自动代理任务中,已完成的子任务在重复执行时不再启用" ] - }, - "4.3.5.0": { - "新增功能": [ - "用户设置中新增连战次数与剩余理智关卡两项配置项", - "支持自动代理时更新MAA" - ], - "修复BUG": [ - "适配MAAv5.16.0基建模式", - "适配自定义基建自动轮换功能" - ], - "程序优化": [ - "移除增效任务" - ] - }, - "4.3.5.2": { - "修复BUG": [ - "修复无法建立网络连接时软件卡死问题" - ] - }, - "4.3.5.1": { - "程序优化": [ - "模拟器路径适配快捷方式" - ] } }, "proxy_list": [