feat(core): 添加公告功能

This commit is contained in:
DLmaster
2025-01-27 21:40:34 +08:00
parent 68db248a7e
commit 170b87e7a8
43 changed files with 40 additions and 21 deletions

View File

@@ -186,6 +186,9 @@ class AUTO_MAA(MSFluentWindow):
# 检查密码
self.setting.check_PASSWORD()
# 获取公告
self.setting.show_notice(if_show=False)
# 检查更新
if Config.global_config.get(Config.global_config.update_IfAutoUpdate):
result = self.setting.get_update_info()

View File

@@ -43,6 +43,7 @@ from qfluentwidgets import (
ExpandGroupSettingCard,
PushSettingCard,
)
from datetime import datetime
import json
import subprocess
import time
@@ -385,41 +386,52 @@ class Setting(QWidget):
self.close()
QApplication.quit()
def show_notice(self):
def show_notice(self, if_show: bool = True):
"""显示公告"""
# 从远程服务器获取最新版本信息
for _ in range(3):
try:
response = requests.get(
"https://gitee.com/DLmaster_361/AUTO_MAA/raw/main/resources/version.json"
"https://gitee.com/DLmaster_361/AUTO_MAA/raw/main/resources/notice.json"
)
version_remote = response.json()
notice = response.json()
break
except Exception as e:
err = e
time.sleep(0.1)
else:
logger.warning(f"获取最新公告时出错:\n{err}")
choice = Dialog(
"网络错误",
f"获取最新公告时出错:\n{err}",
self,
)
if if_show:
choice = Dialog(
"网络错误",
f"获取最新公告时出错:\n{err}",
self,
)
choice.cancelButton.hide()
choice.buttonLayout.insertStretch(1)
choice.exec()
return None
if (Config.app_path / "resources/notice.json").exists():
with (Config.app_path / "resources/notice.json").open(
mode="r", encoding="utf-8"
) as f:
notice_local = json.load(f)
time_local = datetime.strptime(notice_local["time"], "%Y-%m-%d %H:%M")
else:
time_local = datetime.strptime("2000-01-01 00:00", "%Y-%m-%d %H:%M")
if if_show or datetime.strptime(notice["time"], "%Y-%m-%d %H:%M") > time_local:
choice = Dialog("公告", notice["content"], self)
choice.cancelButton.hide()
choice.buttonLayout.insertStretch(1)
if choice.exec():
return None
if "notice" in version_remote:
notice = version_remote["notice"]
else:
notice = "暂无公告~"
choice = Dialog("公告", notice, self)
choice.cancelButton.hide()
choice.buttonLayout.insertStretch(1)
choice.exec()
with (Config.app_path / "resources/notice.json").open(
mode="w", encoding="utf-8"
) as f:
json.dump(notice, f, ensure_ascii=False, indent=4)
class FunctionSettingCard(HeaderCardWidget):

View File

@@ -3,6 +3,7 @@ plyer
PySide6
PySide6-Fluent-Widgets[full]
psutil
opencv-python
pywin32
pyautogui
pycryptodome

Binary file not shown.

BIN
resources/audio/交谈1.wav Normal file

Binary file not shown.

BIN
resources/audio/交谈2.wav Normal file

Binary file not shown.

BIN
resources/audio/交谈3.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
resources/audio/标题.wav Normal file

Binary file not shown.

BIN
resources/audio/生日.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
resources/audio/部署1.wav Normal file

Binary file not shown.

BIN
resources/audio/部署2.wav Normal file

Binary file not shown.

BIN
resources/audio/问候.wav Normal file

Binary file not shown.

BIN
resources/audio/闲置.wav Normal file

Binary file not shown.

Binary file not shown.

4
resources/notice.json Normal file
View File

@@ -0,0 +1,4 @@
{
"content": "公告系统测试中~",
"time": "2025-01-27 17:00"
}

View File

@@ -1,8 +1,7 @@
{
"main_version": "4.2.1.1",
"updater_version": "1.1.0.1",
"announcement": "\n## 新增功能\n- 调度队列上线支持MAA多开\n## 修复BUG\n- 添加了一堆BUG确信\n## 程序优化\n- 界面重构,引入`QFluentWidgets`美化界面",
"notice": "公告系统测试中~",
"announcement": "\n## 新增功能\n- 调度队列上线支持MAA多开\n- 公告系统上线\n## 修复BUG\n- 添加了一堆BUG确信\n## 程序优化\n- 界面重构,引入`QFluentWidgets`美化界面",
"proxy_list": [
"",
"https://gitproxy.click/",