From 0c274ecbe07ada9ebb8a961b2637540ed41d7783 Mon Sep 17 00:00:00 2001 From: DLmaster Date: Sun, 16 Mar 2025 00:22:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(ui):=20=E5=88=9D=E6=AD=A5=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E5=85=AC=E5=91=8A=E7=95=8C=E9=9D=A2=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/ui/Widget.py | 98 ++++++++++++++++++++++++++++++++++++++++++- app/ui/main_window.py | 4 +- app/ui/setting.py | 5 +-- 3 files changed, 100 insertions(+), 7 deletions(-) diff --git a/app/ui/Widget.py b/app/ui/Widget.py index 315d18f..9a2eef8 100644 --- a/app/ui/Widget.py +++ b/app/ui/Widget.py @@ -25,7 +25,14 @@ v4.2 作者:DLmaster_361 """ -from PySide6.QtWidgets import QWidget, QWidget, QLabel, QHBoxLayout, QSizePolicy +from PySide6.QtWidgets import ( + QWidget, + QWidget, + QLabel, + QHBoxLayout, + QVBoxLayout, + QSizePolicy, +) from PySide6.QtCore import Qt, QTime, QTimer, QEvent, QSize from PySide6.QtGui import QIcon, QPixmap, QPainter, QPainterPath from qfluentwidgets import ( @@ -54,12 +61,18 @@ from qfluentwidgets import ( ExpandSettingCard, ToolButton, PushButton, + PrimaryPushButton, ProgressRing, + TextBrowser, + HeaderCardWidget, ) from qfluentwidgets.common.overload import singledispatchmethod import os +import re +import markdown from urllib.parse import urlparse -from typing import Optional, Union, List +from functools import partial +from typing import Optional, Union, List, Dict from app.services import Crypto @@ -155,6 +168,87 @@ class ProgressRingMessageBox(MessageBoxBase): self.timer.deleteLater() +class NoticeMessageBox(MessageBoxBase): + """公告对话框""" + + def __init__(self, parent, content: Dict[str, str]): + super().__init__(parent) + + self.index = self.NoticeIndexCard(content, self) + self.text = TextBrowser(self) + self.text.setOpenExternalLinks(True) + self.button = PrimaryPushButton("确认", self) + + self.buttonGroup.hide() + + self.v_layout = QVBoxLayout() + self.v_layout.addWidget(self.text) + self.v_layout.addWidget(self.button) + + self.h_layout = QHBoxLayout() + self.h_layout.addWidget(self.index) + self.h_layout.addLayout(self.v_layout) + self.h_layout.setStretch(0, 1) + self.h_layout.setStretch(1, 3) + + # 将组件添加到布局中 + self.viewLayout.addLayout(self.h_layout) + self.widget.setFixedSize(800, 600) + + self.index.index_changed.connect(self.__update_text) + self.button.clicked.connect(self.yesButton.click) + self.index.index_cards[0].clicked.emit() + + def __update_text(self, text: str): + + html = markdown.markdown(text).replace("\n", "") + html = re.sub( + r"(.*?)", + r"\1", + html, + ) + html = re.sub(r"
  • (.*?)

  • ", r"

    \1

    ", html) + html = re.sub(r"", r"\1", html) + + self.text.setHtml(html) + + class NoticeIndexCard(HeaderCardWidget): + + index_changed = Signal(str) + + def __init__(self, content: Dict[str, str], parent=None): + super().__init__(parent) + self.setTitle("公告") + + self.Layout = QVBoxLayout() + self.viewLayout.addLayout(self.Layout) + self.viewLayout.setContentsMargins(3, 0, 3, 3) + + self.index_cards: List[QuantifiedItemCard] = [] + + if content: + self.index_cards.append(QuantifiedItemCard(["ALL", ""])) + self.index_cards[-1].clicked.connect( + lambda: self.index_changed.emit( + "\n---\n".join( + [str(_) for _ in content.values() if isinstance(_, str)] + ) + ) + ) + self.Layout.addWidget(self.index_cards[-1]) + else: + self.Layout.addWidget(QuantifiedItemCard(["暂无公告", ""])) + for index, text in content.items(): + + self.index_cards.append(QuantifiedItemCard([index, ""])) + self.index_cards[-1].clicked.connect( + partial(self.index_changed.emit, text) + ) + self.Layout.addWidget(self.index_cards[-1]) + + self.Layout.addStretch(1) + + class LineEditSettingCard(SettingCard): """Setting card with LineEdit""" diff --git a/app/ui/main_window.py b/app/ui/main_window.py index ecf32ab..3bbba97 100644 --- a/app/ui/main_window.py +++ b/app/ui/main_window.py @@ -210,12 +210,12 @@ class AUTO_MAA(MSFluentWindow): """切换主题""" setTheme(Theme.AUTO, lazy=True) - QTimer.singleShot(100, lambda: setTheme(Theme.AUTO, lazy=True)) + QTimer.singleShot(500, lambda: setTheme(Theme.AUTO, lazy=True)) # 云母特效启用时需要增加重试机制 if self.isMicaEffectEnabled(): QTimer.singleShot( - 100, + 500, lambda: self.windowEffect.setMicaEffect(self.winId(), isDarkTheme()), ) diff --git a/app/ui/setting.py b/app/ui/setting.py index 9b70124..9e29325 100644 --- a/app/ui/setting.py +++ b/app/ui/setting.py @@ -62,6 +62,7 @@ from .Widget import ( LineEditSettingCard, PasswordLineEditSettingCard, UrlListSettingCard, + NoticeMessageBox, ) @@ -465,9 +466,7 @@ class Setting(QWidget): and datetime.strptime(notice["time"], "%Y-%m-%d %H:%M") > time_local ): - choice = Dialog("公告", notice["content"], self) - choice.cancelButton.hide() - choice.buttonLayout.insertStretch(1) + choice = NoticeMessageBox(self.window(), notice["notice_dict"]) if choice.exec(): with (Config.app_path / "resources/notice.json").open( mode="w", encoding="utf-8" From 675e11960aa466d9cd28036611210d165db25556 Mon Sep 17 00:00:00 2001 From: DLmaster Date: Sun, 16 Mar 2025 01:01:23 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix(ui):=20=E8=A1=A5=E5=85=85=E7=BD=91?= =?UTF-8?q?=E5=9D=80=E5=A4=96=E9=93=BE=E8=B0=83=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/ui/Widget.py | 5 ++++- requirements.txt | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/ui/Widget.py b/app/ui/Widget.py index 9a2eef8..0a4026b 100644 --- a/app/ui/Widget.py +++ b/app/ui/Widget.py @@ -207,10 +207,13 @@ class NoticeMessageBox(MessageBoxBase): r"\1", html, ) + html = re.sub( + r'(]*href="[^"]+"[^>]*)>', r'\1 style="color: #009faa;">', html + ) html = re.sub(r"
  • (.*?)

  • ", r"

    \1

    ", html) html = re.sub(r"
      (.*?)
    ", r"\1", html) - self.text.setHtml(html) + self.text.setHtml(f"{html}") class NoticeIndexCard(HeaderCardWidget): diff --git a/requirements.txt b/requirements.txt index a8597de..202a67a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ pywin32 pyautogui pycryptodome requests +markdown Jinja2 serverchan_sdk nuitka==2.6 \ No newline at end of file From 62e5bb30e2223857e7eb79aa7046d4efa38112cb Mon Sep 17 00:00:00 2001 From: DLmaster Date: Sun, 16 Mar 2025 01:10:13 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat(ui):=20=E5=85=AC=E5=91=8A=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/version.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/version.json b/resources/version.json index 97cb08a..d8b1b31 100644 --- a/resources/version.json +++ b/resources/version.json @@ -1,7 +1,7 @@ { - "main_version": "4.2.5.4", + "main_version": "4.2.5.5", "updater_version": "1.2.0.0", - "announcement": "\n## 新增功能\n- 屏蔽MuMu模拟器开屏广告功能上线\n- 更新器支持多线程下载\n- 添加强制关闭ADB与模拟器等增强任务项\n## 修复BUG\n- 修复统计信息HTML模板公招匹配错误\n- 修复密码显示按钮动画异常\n- 修复`检测到MAA未能实际执行任务`报错被异常屏蔽\n- 修复MAA超时判定异常失效\n## 程序优化\n- 关机等电源操作添加100s倒计时\n- 人工排查弹窗方法优化\n- 人工排查时自动屏蔽静默操作", + "announcement": "\n## 新增功能\n- 屏蔽MuMu模拟器开屏广告功能上线\n- 更新器支持多线程下载\n- 添加强制关闭ADB与模拟器等增强任务项\n## 修复BUG\n- 修复统计信息HTML模板公招匹配错误\n- 修复密码显示按钮动画异常\n- 修复`检测到MAA未能实际执行任务`报错被异常屏蔽\n- 修复MAA超时判定异常失效\n## 程序优化\n- 关机等电源操作添加100s倒计时\n- 人工排查弹窗方法优化\n- 人工排查时自动屏蔽静默操作\n- 公告样式优化", "proxy_list": [ "", "https://gitproxy.click/",