From 41412e1ef4f713bf639a3dc79009d32922e123d9 Mon Sep 17 00:00:00 2001 From: DLmaster361 Date: Sun, 4 May 2025 15:18:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E6=96=B0=E5=A2=9E`=E6=97=A0?= =?UTF-8?q?=E4=BA=BA=E5=80=BC=E5=AE=88=E6=A8=A1=E5=BC=8F`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-app.yml | 15 -------- app/core/config.py | 4 ++ app/core/main_info_bar.py | 10 ++--- app/core/task_manager.py | 7 ++-- app/core/timer.py | 3 ++ app/services/system.py | 8 ++-- app/ui/main_window.py | 8 ++-- app/ui/setting.py | 65 +++++++++++++++++++++++++++------ app/utils/downloader.py | 6 +-- resources/version.json | 6 ++- 10 files changed, 79 insertions(+), 53 deletions(-) diff --git a/.github/workflows/build-app.yml b/.github/workflows/build-app.yml index 9ae66d2..0b27c92 100644 --- a/.github/workflows/build-app.yml +++ b/.github/workflows/build-app.yml @@ -135,18 +135,3 @@ jobs: - name: Upload Release to Server run: | scp -r artifacts/* ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:/home/user/files/AUTO_MAA/ - - name: Install obsutil - run: | - wget https://obs-community.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_linux_amd64.tar.gz - tar -xzvf obsutil_linux_amd64.tar.gz --strip-components=1 - chmod 755 obsutil - ./obsutil version - - name: Upload Release to Huawei OBS - env: - OBS_AK: ${{ secrets.OBS_AK }} - OBS_SK: ${{ secrets.OBS_SK }} - OBS_ENDPOINT: ${{ secrets.OBS_ENDPOINT }} - OBS_BUCKET: ${{ secrets.OBS_BUCKET }} - run: | - ./obsutil config -i $OBS_AK -k $OBS_SK -e $OBS_ENDPOINT - ./obsutil cp artifacts/ obs://$OBS_BUCKET/releases/ -r -f diff --git a/app/core/config.py b/app/core/config.py index 0115f82..0729d4e 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -103,6 +103,9 @@ class GlobalConfig(QConfig): "Function", "IfSilence", False, BoolValidator() ) self.function_BossKey = ConfigItem("Function", "BossKey", "") + self.function_UnattendedMode = ConfigItem( + "Function", "UnattendedMode", False, BoolValidator() + ) self.function_IfAgreeBilibili = ConfigItem( "Function", "IfAgreeBilibili", False, BoolValidator() ) @@ -633,6 +636,7 @@ class AppConfig(GlobalConfig): self.gameid_path = self.app_path / "data/gameid.txt" self.version_path = self.app_path / "resources/version.json" + self.main_window = None self.PASSWORD = "" self.running_list = [] self.silence_list = [] diff --git a/app/core/main_info_bar.py b/app/core/main_info_bar.py index 729bb11..791f8c4 100644 --- a/app/core/main_info_bar.py +++ b/app/core/main_info_bar.py @@ -29,17 +29,15 @@ from loguru import logger from PySide6.QtCore import Qt from qfluentwidgets import InfoBar, InfoBarPosition +from .config import Config + class _MainInfoBar: """信息通知栏""" - def __init__(self, main_window=None): - - self.main_window = main_window - def push_info_bar(self, mode: str, title: str, content: str, time: int): """推送到信息通知栏""" - if self.main_window is None: + if Config.main_window is None: logger.error("信息通知栏未设置父窗口") return None @@ -61,7 +59,7 @@ class _MainInfoBar: isClosable=True, position=InfoBarPosition.TOP_RIGHT, duration=time, - parent=self.main_window, + parent=Config.main_window, ) else: logger.error(f"未知的通知栏模式: {mode}") diff --git a/app/core/task_manager.py b/app/core/task_manager.py index 51ad27f..868f611 100644 --- a/app/core/task_manager.py +++ b/app/core/task_manager.py @@ -173,10 +173,9 @@ class _TaskManager(QObject): create_gui = Signal(Task) connect_gui = Signal(Task) - def __init__(self, main_window=None): + def __init__(self): super(_TaskManager, self).__init__() - self.main_window = main_window self.task_dict: Dict[str, Task] = {} def add_task( @@ -279,7 +278,7 @@ class _TaskManager(QObject): } choice = ProgressRingMessageBox( - self.main_window, + Config.main_window, f"{mode_book[Config.queue_dict[name]["Config"].get(Config.queue_dict[name]["Config"].queueSet_AfterAccomplish)]}倒计时", ) if choice.exec(): @@ -325,7 +324,7 @@ class _TaskManager(QObject): def push_dialog(self, name: str, title: str, content: str): """推送对话框""" - choice = MessageBox(title, content, self.main_window) + choice = MessageBox(title, content, Config.main_window) choice.yesButton.setText("是") choice.cancelButton.setText("否") diff --git a/app/core/timer.py b/app/core/timer.py index 3679fd9..f019076 100644 --- a/app/core/timer.py +++ b/app/core/timer.py @@ -55,6 +55,9 @@ class _MainTimer(QWidget): """长时间定期检定任务""" Config.get_gameid() + Config.main_window.setting.show_notice() + if Config.get(Config.update_IfAutoUpdate): + Config.main_window.setting.check_update() def timed_start(self): """定时启动代理任务""" diff --git a/app/services/system.py b/app/services/system.py index f329487..32f4491 100644 --- a/app/services/system.py +++ b/app/services/system.py @@ -44,9 +44,7 @@ class _SystemHandler: ES_CONTINUOUS = 0x80000000 ES_SYSTEM_REQUIRED = 0x00000001 - def __init__(self, main_window: QWidget = None): - - self.main_window = main_window + def __init__(self): self.set_Sleep() self.set_SelfStart() @@ -112,7 +110,7 @@ class _SystemHandler: elif mode == "KillSelf": - self.main_window.close() + Config.main_window.close() QApplication.quit() elif sys.platform.startswith("linux"): @@ -138,7 +136,7 @@ class _SystemHandler: elif mode == "KillSelf": - self.main_window.close() + Config.main_window.close() QApplication.quit() def is_startup(self) -> bool: diff --git a/app/ui/main_window.py b/app/ui/main_window.py index 9baa317..e3acc55 100644 --- a/app/ui/main_window.py +++ b/app/ui/main_window.py @@ -77,9 +77,7 @@ class AUTO_MAA(MSFluentWindow): self.splashScreen = SplashScreen(self.windowIcon(), self) self.show_ui("显示主窗口", if_quick=True) - TaskManager.main_window = self.window() - MainInfoBar.main_window = self.window() - System.main_window = self.window() + Config.main_window = self.window() # 创建主窗口 self.home = Home(self) @@ -269,11 +267,11 @@ class AUTO_MAA(MSFluentWindow): self.start_main_task() # 获取公告 - self.setting.show_notice(if_show=False) + self.setting.show_notice(if_first=True) # 检查更新 if Config.get(Config.update_IfAutoUpdate): - self.setting.check_update() + self.setting.check_update(if_first=True) # 直接最小化 if Config.get(Config.start_IfMinimizeDirectly): diff --git a/app/ui/setting.py b/app/ui/setting.py index 1f3fd62..fe94877 100644 --- a/app/ui/setting.py +++ b/app/ui/setting.py @@ -87,9 +87,9 @@ class Setting(QWidget): self.start.card_IfSelfStart.checkedChanged.connect(System.set_SelfStart) self.security.card_changePASSWORD.clicked.connect(self.change_PASSWORD) self.updater.card_CheckUpdate.clicked.connect( - lambda: self.check_update(if_click=True) + lambda: self.check_update(if_show=True) ) - self.other.card_Notice.clicked.connect(self.show_notice) + self.other.card_Notice.clicked.connect(lambda: self.show_notice(if_show=True)) content_layout.addWidget(self.function) content_layout.addWidget(self.start) @@ -255,12 +255,12 @@ class Setting(QWidget): if choice.exec(): break - def check_update(self, if_click: bool = False) -> None: + def check_update(self, if_show: bool = False, if_first: bool = False) -> None: """检查版本更新,调起文件下载进程""" current_version = list(map(int, Config.VERSION.split("."))) - if Network.if_running and if_click: + if Network.if_running and if_show: MainInfoBar.push_info_bar( "warning", "请求速度过快", "上个网络请求还未结束,请稍等片刻", 5000 ) @@ -330,8 +330,14 @@ class Setting(QWidget): ) ) - # 有版本更新 - if version.parse(version_text(remote_version)) > version.parse( + if ( + if_show + or ( + not if_show + and if_first + and not Config.get(Config.function_UnattendedMode) + ) + ) and version.parse(version_text(remote_version)) > version.parse( version_text(current_version) ): @@ -407,11 +413,26 @@ class Setting(QWidget): self.window().close() QApplication.quit() - # 无版本更新 - else: - MainInfoBar.push_info_bar("success", "更新检查", "已是最新版本~", 3000) + elif ( + if_show + or if_first + or version.parse(version_text(remote_version)) + > version.parse(version_text(current_version)) + ): - def show_notice(self, if_show: bool = True) -> None: + if version.parse(version_text(remote_version)) > version.parse( + version_text(current_version) + ): + MainInfoBar.push_info_bar( + "info", + "发现新版本", + f"{version_text(current_version)} --> {version_text(remote_version)}", + 3600000, + ) + else: + MainInfoBar.push_info_bar("success", "更新检查", "已是最新版本~", 3000) + + def show_notice(self, if_show: bool = False, if_first: bool = False) -> None: """显示公告""" # 从远程服务器获取最新公告 @@ -450,9 +471,11 @@ class Setting(QWidget): } if if_show or ( - datetime.now() + if_first + and datetime.now() > datetime.strptime(notice["time"], "%Y-%m-%d %H:%M") > time_local + and not Config.get(Config.function_UnattendedMode) ): choice = NoticeMessageBox(self.window(), "公告", notice["notice_dict"]) @@ -464,6 +487,17 @@ class Setting(QWidget): ) as f: json.dump(notice, f, ensure_ascii=False, indent=4) + elif ( + datetime.now() + > datetime.strptime(notice["time"], "%Y-%m-%d %H:%M") + > time_local + ): + + MainInfoBar.push_info_bar( + "info", "有新公告", "请前往设置界面查看公告", 3600000 + ) + return None + class FunctionSettingCard(HeaderCardWidget): @@ -498,6 +532,14 @@ class FunctionSettingCard(HeaderCardWidget): parent=self, ) self.card_IfSilence = self.SilenceSettingCard(self) + self.card_UnattendedMode = SwitchSettingCard( + icon=FluentIcon.PAGE_RIGHT, + title="无人值守模式", + content="开启后AUTO_MAA不再主动弹出对话框,以免影响代理任务运行", + qconfig=Config, + configItem=Config.function_UnattendedMode, + parent=self, + ) self.card_IfAgreeBilibili = SwitchSettingCard( icon=FluentIcon.PAGE_RIGHT, title="托管bilibili游戏隐私政策", @@ -520,6 +562,7 @@ class FunctionSettingCard(HeaderCardWidget): Layout.addWidget(self.card_HistoryRetentionTime) Layout.addWidget(self.card_IfAllowSleep) Layout.addWidget(self.card_IfSilence) + Layout.addWidget(self.card_UnattendedMode) Layout.addWidget(self.card_IfAgreeBilibili) Layout.addWidget(self.card_IfSkipMumuSplashAds) self.viewLayout.addLayout(Layout) diff --git a/app/utils/downloader.py b/app/utils/downloader.py index c61ea84..769eb5e 100644 --- a/app/utils/downloader.py +++ b/app/utils/downloader.py @@ -613,11 +613,7 @@ class DownloadManager(QDialog): class AUTO_MAA_Downloader(QApplication): def __init__( - self, - app_path: Path, - name: str, - main_version: list, - config: dict, + self, app_path: Path, name: str, main_version: list, config: dict ) -> None: super().__init__() diff --git a/resources/version.json b/resources/version.json index 6bf962d..80e1bd1 100644 --- a/resources/version.json +++ b/resources/version.json @@ -4,6 +4,9 @@ "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.2": { + "新增功能": [ + "新增`无人值守模式`" + ], "修复BUG": [ "修复软件窗口最大化异常问题", "修复异常操作导致窗口离开屏幕后难以复原的问题", @@ -52,7 +55,6 @@ "https://ghfast.top/" ], "download_dict": { - "官方下载站-jp": "https://jp-download.fearr.xyz/AUTO_MAA/", - "官方下载站-hw": "http://hwobs.fearr.xyz/releases/artifacts/" + "官方下载站-jp": "https://jp-download.fearr.xyz/AUTO_MAA/" } } \ No newline at end of file