diff --git a/app/core/config.py b/app/core/config.py index f832252..1496a6e 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -39,6 +39,7 @@ from qfluentwidgets import ( FolderValidator, BoolValidator, RangeValidator, + OptionsValidator, qconfig, ) @@ -560,12 +561,17 @@ class GlobalConfig(QConfig): notify_ServerChanKey = ConfigItem("Notify", "ServerChanKey", "") notify_ServerChanChannel = ConfigItem("Notify", "ServerChanChannel", "") notify_ServerChanTag = ConfigItem("Notify", "ServerChanTag", "") - notify_IfCompanyWebHookBot = ConfigItem("Notify", "IfCompanyWebHookBot", False, BoolValidator()) + notify_IfCompanyWebHookBot = ConfigItem( + "Notify", "IfCompanyWebHookBot", False, BoolValidator() + ) notify_CompanyWebHookBotUrl = ConfigItem("Notify", "CompanyWebHookBotUrl", "") notify_IfPushDeer = ConfigItem("Notify", "IfPushDeer", False, BoolValidator()) notify_IfPushDeerKey = ConfigItem("Notify", "PushDeerKey", "") update_IfAutoUpdate = ConfigItem("Update", "IfAutoUpdate", False, BoolValidator()) + update_UpdateType = OptionsConfigItem( + "Update", "UpdateType", "main", OptionsValidator(["main", "dev"]) + ) class QueueConfig(QConfig): diff --git a/app/ui/main_window.py b/app/ui/main_window.py index 47a5a22..e5de864 100644 --- a/app/ui/main_window.py +++ b/app/ui/main_window.py @@ -182,6 +182,7 @@ class AUTO_MAA(MSFluentWindow): # 加载配置 qconfig.load(Config.config_path, Config.global_config) + Config.global_config.save() # 检查密码 self.setting.check_PASSWORD() diff --git a/app/ui/setting.py b/app/ui/setting.py index 1ef9a57..f902c37 100644 --- a/app/ui/setting.py +++ b/app/ui/setting.py @@ -42,6 +42,7 @@ from qfluentwidgets import ( SwitchSettingCard, ExpandGroupSettingCard, PushSettingCard, + ComboBoxSettingCard, ) from datetime import datetime import json @@ -207,7 +208,7 @@ class Setting(QWidget): for _ in range(3): try: response = requests.get( - "https://gitee.com/DLmaster_361/AUTO_MAA/raw/main/resources/version.json" + f"https://gitee.com/DLmaster_361/AUTO_MAA/raw/{Config.global_config.get(Config.global_config.update_UpdateType)}/resources/version.json" ) version_remote = response.json() break @@ -249,7 +250,7 @@ class Setting(QWidget): for _ in range(3): try: response = requests.get( - "https://gitee.com/DLmaster_361/AUTO_MAA/raw/main/resources/version.json" + f"https://gitee.com/DLmaster_361/AUTO_MAA/raw/{Config.global_config.get(Config.global_config.update_UpdateType)}/resources/version.json" ) version_remote = response.json() break @@ -666,6 +667,7 @@ class NotifySettingCard(HeaderCardWidget): self.viewLayout.setContentsMargins(0, 0, 0, 0) self.viewLayout.setSpacing(0) self.addGroupWidget(widget) + widget = QWidget() Layout = QVBoxLayout(widget) @@ -695,18 +697,21 @@ class UpdaterSettingCard(HeaderCardWidget): def __init__(self, parent=None): super().__init__(parent) - self.setTitle("更新") - Layout = QVBoxLayout() - self.card_IfAutoUpdate = SwitchSettingCard( icon=FluentIcon.PAGE_RIGHT, title="自动检查更新", content="将在启动时自动检查AUTO_MAA是否有新版本", configItem=Config.global_config.update_IfAutoUpdate, ) - + self.card_UpdateType = ComboBoxSettingCard( + configItem=Config.global_config.update_UpdateType, + icon=FluentIcon.PAGE_RIGHT, + title="版本更新类别", + content="选择AUTO_MAA的更新类别", + texts=["稳定版", "公测版"], + ) self.card_CheckUpdate = PushSettingCard( text="检查更新", icon=FluentIcon.UPDATE, @@ -714,9 +719,10 @@ class UpdaterSettingCard(HeaderCardWidget): content="检查AUTO_MAA是否有新版本", ) + Layout = QVBoxLayout() Layout.addWidget(self.card_IfAutoUpdate) + Layout.addWidget(self.card_UpdateType) Layout.addWidget(self.card_CheckUpdate) - self.viewLayout.addLayout(Layout) @@ -760,7 +766,6 @@ class OtherSettingCard(HeaderCardWidget): parent, ) - self.card_GitHubRepository = HyperlinkCard( url="https://github.com/DLmaster361/AUTO_MAA", text="访问GitHub仓库", diff --git a/app/utils/Updater.py b/app/utils/Updater.py index 3ba46fa..1b27cba 100644 --- a/app/utils/Updater.py +++ b/app/utils/Updater.py @@ -333,11 +333,19 @@ if __name__ == "__main__": else: main_version_current = [0, 0, 0, 0] + # 从本地配置文件获取更新类型 + if (app_path / "config/config.json").exists(): + with (app_path / "config/config.json").open(mode="r", encoding="utf-8") as f: + config = json.load(f) + update_type = config["Update"]["UpdateType"] + else: + update_type = "main" + # 从远程服务器获取最新版本信息 for _ in range(3): try: response = requests.get( - "https://gitee.com/DLmaster_361/AUTO_MAA/raw/main/resources/version.json" + f"https://gitee.com/DLmaster_361/AUTO_MAA/raw/{update_type}/resources/version.json" ) version_remote = response.json() main_version_remote = list( diff --git a/resources/version.json b/resources/version.json index d47c1a0..af668c3 100644 --- a/resources/version.json +++ b/resources/version.json @@ -1,7 +1,7 @@ { "main_version": "4.2.2.2", "updater_version": "1.1.1.0", - "announcement": "\n## 新增功能\n- 添加用户每日代理次数上限功能 #15\n- 新增代理成功消息推送渠道Server酱与企业微信群机器人推送\n## 修复BUG\n- 修复自定义基建无法正常使用的问题\n- 修正人工排查文案\n## 程序优化\n- 无", + "announcement": "\n## 新增功能\n- 添加用户每日代理次数上限功能 #15\n- 新增代理成功消息推送渠道Server酱与企业微信群机器人推送\n- 添加更新类别可选项\n## 修复BUG\n- 修复自定义基建无法正常使用的问题\n- 修正人工排查文案\n- 修复高级MAA配置序号错位\n- 修复高级用户列表无法配置问题\n- 修复主调度台选项乱动问题\n- 修复更新器文件夹定位问题\n## 程序优化\n- 无", "proxy_list": [ "", "https://gitproxy.click/",