diff --git a/app/ui/Widget.py b/app/ui/Widget.py
index 315d18f..0a4026b 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,90 @@ 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'(]*href="[^"]+"[^>]*)>', r'\1 style="color: #009faa;">', html
+ )
+ html = re.sub(r"(.*?)
", r"◆ \1
", html)
+ html = re.sub(r"", r"\1", html)
+
+ self.text.setHtml(f"{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"
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
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/",