diff --git a/app/core/config.py b/app/core/config.py index 4e72895..b99afff 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -567,7 +567,7 @@ class MaaPlanConfig(LQConfig): class AppConfig(GlobalConfig): - VERSION = "4.3.8.4" + VERSION = "4.3.8.0" gameid_refreshed = Signal() PASSWORD_refreshed = Signal() @@ -591,6 +591,7 @@ class AppConfig(GlobalConfig): self.PASSWORD = "" self.running_list = [] self.silence_list = [] + self.info_bar_list = [] self.gameid_dict = { "ALL": {"value": [], "text": []}, "Monday": {"value": [], "text": []}, diff --git a/app/core/main_info_bar.py b/app/core/main_info_bar.py index 791f8c4..399774d 100644 --- a/app/core/main_info_bar.py +++ b/app/core/main_info_bar.py @@ -35,23 +35,30 @@ from .config import Config class _MainInfoBar: """信息通知栏""" - def push_info_bar(self, mode: str, title: str, content: str, time: int): + # 模式到 InfoBar 方法的映射 + mode_mapping = { + "success": InfoBar.success, + "warning": InfoBar.warning, + "error": InfoBar.error, + "info": InfoBar.info, + } + + def push_info_bar( + self, mode: str, title: str, content: str, time: int, if_force: bool = False + ): """推送到信息通知栏""" if Config.main_window is None: logger.error("信息通知栏未设置父窗口") return None - # 定义模式到 InfoBar 方法的映射 - mode_mapping = { - "success": InfoBar.success, - "warning": InfoBar.warning, - "error": InfoBar.error, - "info": InfoBar.info, - } - # 根据 mode 获取对应的 InfoBar 方法 - info_bar_method = mode_mapping.get(mode) - if info_bar_method: + info_bar_method = self.mode_mapping.get(mode) + + if not info_bar_method: + logger.error(f"未知的通知栏模式: {mode}") + return None + + if Config.main_window.isVisible(): info_bar_method( title=title, content=content, @@ -61,8 +68,16 @@ class _MainInfoBar: duration=time, parent=Config.main_window, ) - else: - logger.error(f"未知的通知栏模式: {mode}") + elif if_force: + # 如果主窗口不可见且强制推送,则录入消息队列等待窗口显示后推送 + info_bar_item = { + "mode": mode, + "title": title, + "content": content, + "time": time, + } + if info_bar_item not in Config.info_bar_list: + Config.info_bar_list.append(info_bar_item) MainInfoBar = _MainInfoBar() diff --git a/app/ui/main_window.py b/app/ui/main_window.py index 76aac32..a7a72d0 100644 --- a/app/ui/main_window.py +++ b/app/ui/main_window.py @@ -302,6 +302,15 @@ class AUTO_MAA(MSFluentWindow): self.window().raise_() self.window().activateWindow() + while Config.info_bar_list: + info_bar_item = Config.info_bar_list.pop(0) + MainInfoBar.push_info_bar( + info_bar_item["mode"], + info_bar_item["title"], + info_bar_item["content"], + info_bar_item["time"], + ) + elif mode == "配置托盘": if Config.get(Config.ui_IfShowTray): diff --git a/app/ui/setting.py b/app/ui/setting.py index e26ead3..84fda41 100644 --- a/app/ui/setting.py +++ b/app/ui/setting.py @@ -462,6 +462,7 @@ class Setting(QWidget): "发现新版本", f"{version_text(current_version)} --> {version_text(remote_version)}", 3600000, + if_force=True, ) else: MainInfoBar.push_info_bar("success", "更新检查", "已是最新版本~", 3000) @@ -545,7 +546,7 @@ class Setting(QWidget): ): MainInfoBar.push_info_bar( - "info", "有新公告", "请前往设置界面查看公告", 3600000 + "info", "有新公告", "请前往设置界面查看公告", 3600000, if_force=True ) return None diff --git a/resources/version.json b/resources/version.json index bc0525c..c0e4e71 100644 --- a/resources/version.json +++ b/resources/version.json @@ -1,6 +1,11 @@ { - "main_version": "4.3.8.4", + "main_version": "4.3.8.0", "version_info": { + "4.3.8.0": { + "新增功能": [ + "吐司通知在主窗口隐藏时不再弹出" + ] + }, "4.3.8.4": { "新增功能": [ "支持为每一个用户执行独立通知", @@ -29,7 +34,7 @@ "日志分析忽略MAA超时提示" ], "程序优化": [ - "配置类定义方法更新" + "配置类定义方法优化" ] }, "4.3.8.1": { @@ -44,14 +49,6 @@ "程序优化": [ "UI样式优化,进一步适配win10主题" ] - }, - "4.3.7.0": { - "新增功能": [ - "下载器支持完整mirrorc列表" - ], - "程序优化": [ - "重构更新逻辑,去除独立更新器" - ] } } } \ No newline at end of file