feat(utils): 更新器优化

- 更新信息样式优化
- 更新器支持动态获取下载站
This commit is contained in:
DLmaster
2025-03-18 22:56:33 +08:00
parent dd022cf356
commit 52affc0d76
6 changed files with 176 additions and 50 deletions

View File

@@ -160,3 +160,18 @@ jobs:
- name: Upload Release to Server - name: Upload Release to Server
run: | run: |
scp -r artifacts/* ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:/home/user/files/AUTO_MAA/ 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

View File

@@ -160,3 +160,18 @@ jobs:
- name: Upload Release to Server - name: Upload Release to Server
run: | run: |
scp -r artifacts/* ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:/home/user/files/AUTO_MAA/ 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

View File

@@ -171,19 +171,23 @@ class ProgressRingMessageBox(MessageBoxBase):
class NoticeMessageBox(MessageBoxBase): class NoticeMessageBox(MessageBoxBase):
"""公告对话框""" """公告对话框"""
def __init__(self, parent, content: Dict[str, str]): def __init__(self, parent, title: str, content: Dict[str, str]):
super().__init__(parent) super().__init__(parent)
self.index = self.NoticeIndexCard(content, self) self.index = self.NoticeIndexCard(title, content, self)
self.text = TextBrowser(self) self.text = TextBrowser(self)
self.text.setOpenExternalLinks(True) self.text.setOpenExternalLinks(True)
self.button = PrimaryPushButton("确认", self) self.button_yes = PrimaryPushButton("确认", self)
self.button_cancel = PrimaryPushButton("取消", self)
self.buttonGroup.hide() self.buttonGroup.hide()
self.v_layout = QVBoxLayout() self.v_layout = QVBoxLayout()
self.v_layout.addWidget(self.text) self.v_layout.addWidget(self.text)
self.v_layout.addWidget(self.button) self.button_layout = QHBoxLayout()
self.button_layout.addWidget(self.button_yes)
self.button_layout.addWidget(self.button_cancel)
self.v_layout.addLayout(self.button_layout)
self.h_layout = QHBoxLayout() self.h_layout = QHBoxLayout()
self.h_layout.addWidget(self.index) self.h_layout.addWidget(self.index)
@@ -196,7 +200,8 @@ class NoticeMessageBox(MessageBoxBase):
self.widget.setFixedSize(800, 600) self.widget.setFixedSize(800, 600)
self.index.index_changed.connect(self.__update_text) self.index.index_changed.connect(self.__update_text)
self.button.clicked.connect(self.yesButton.click) self.button_yes.clicked.connect(self.yesButton.click)
self.button_cancel.clicked.connect(self.cancelButton.click)
self.index.index_cards[0].clicked.emit() self.index.index_cards[0].clicked.emit()
def __update_text(self, text: str): def __update_text(self, text: str):
@@ -219,9 +224,9 @@ class NoticeMessageBox(MessageBoxBase):
index_changed = Signal(str) index_changed = Signal(str)
def __init__(self, content: Dict[str, str], parent=None): def __init__(self, title: str, content: Dict[str, str], parent=None):
super().__init__(parent) super().__init__(parent)
self.setTitle("公告") self.setTitle(title)
self.Layout = QVBoxLayout() self.Layout = QVBoxLayout()
self.viewLayout.addLayout(self.Layout) self.viewLayout.addLayout(self.Layout)
@@ -229,18 +234,6 @@ class NoticeMessageBox(MessageBoxBase):
self.index_cards: List[QuantifiedItemCard] = [] 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(): for index, text in content.items():
self.index_cards.append(QuantifiedItemCard([index, ""])) self.index_cards.append(QuantifiedItemCard([index, ""]))
@@ -249,6 +242,9 @@ class NoticeMessageBox(MessageBoxBase):
) )
self.Layout.addWidget(self.index_cards[-1]) self.Layout.addWidget(self.index_cards[-1])
if not content:
self.Layout.addWidget(QuantifiedItemCard(["暂无信息", ""]))
self.Layout.addStretch(1) self.Layout.addStretch(1)

View File

@@ -53,6 +53,7 @@ import requests
import subprocess import subprocess
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
from typing import Dict, List, Union
from app.core import Config, MainInfoBar from app.core import Config, MainInfoBar
from app.services import Crypto, System from app.services import Crypto, System
@@ -305,7 +306,9 @@ class Setting(QWidget):
# 从本地版本信息文件获取当前版本信息 # 从本地版本信息文件获取当前版本信息
with Config.version_path.open(mode="r", encoding="utf-8") as f: with Config.version_path.open(mode="r", encoding="utf-8") as f:
version_current = json.load(f) version_current: Dict[
str, Union[str, Dict[str, Union[str, Dict[str, List[str]]]]]
] = json.load(f)
main_version_current = list( main_version_current = list(
map(int, version_current["main_version"].split(".")) map(int, version_current["main_version"].split("."))
) )
@@ -322,7 +325,9 @@ class Setting(QWidget):
response = requests.get( response = requests.get(
f"https://gitee.com/DLmaster_361/AUTO_MAA/raw/{Config.global_config.get(Config.global_config.update_UpdateType)}/resources/version.json" f"https://gitee.com/DLmaster_361/AUTO_MAA/raw/{Config.global_config.get(Config.global_config.update_UpdateType)}/resources/version.json"
) )
version_remote = response.json() version_remote: Dict[
str, Union[str, Dict[str, Union[str, Dict[str, List[str]]]]]
] = response.json()
break break
except Exception as e: except Exception as e:
err = e err = e
@@ -360,25 +365,48 @@ class Setting(QWidget):
# 生成版本更新信息 # 生成版本更新信息
if main_version_remote > main_version_current: if main_version_remote > main_version_current:
main_version_info = f" 主程序:{version_text(main_version_current)} --> {version_text(main_version_remote)}\n" main_version_info = f"## 主程序:{version_text(main_version_current)} --> {version_text(main_version_remote)}\n\n"
else: else:
main_version_info = ( main_version_info = (
f" 主程序:{version_text(main_version_current)}\n" f"## 主程序:{version_text(main_version_current)}\n\n"
) )
if updater_version_remote > updater_version_current: if updater_version_remote > updater_version_current:
updater_version_info = f" 更新器:{version_text(updater_version_current)} --> {version_text(updater_version_remote)}\n" updater_version_info = f"## 更新器:{version_text(updater_version_current)} --> {version_text(updater_version_remote)}\n\n"
else: else:
updater_version_info = ( updater_version_info = (
f" 更新器:{version_text(updater_version_current)}\n" f"## 更新器:{version_text(updater_version_current)}\n\n"
) )
update_version_info = {}
all_version_info = {}
for v_i in [
info
for version, info in version_remote["version_info"].items()
if list(map(int, version.split("."))) > main_version_current
]:
for key, value in v_i.items():
if key in update_version_info:
update_version_info[key] += value.copy()
else:
update_version_info[key] = value.copy()
for v_i in version_remote["version_info"].values():
for key, value in v_i.items():
if key in all_version_info:
all_version_info[key] += value.copy()
else:
all_version_info[key] = value.copy()
version_info = {
"更新总览": f"{main_version_info}{updater_version_info}{version_info_markdown(update_version_info)}",
"ALL~版本信息": version_info_markdown(all_version_info),
**{
version_text(list(map(int, k.split(".")))): version_info_markdown(v)
for k, v in version_remote["version_info"].items()
},
}
# 询问是否开始版本更新 # 询问是否开始版本更新
if if_question: if if_question:
choice = MessageBox( choice = NoticeMessageBox(self.window(), "版本更新", version_info)
"版本更新",
f"发现新版本:\n{main_version_info}{updater_version_info} 更新说明:\n{version_remote['announcement'].replace("\n# ","\n ").replace("\n## ","\n - ").replace("\n- ","\n · ")}\n\n是否开始更新?\n\n 注意主程序更新时AUTO_MAA将自动关闭",
self.window(),
)
if not choice.exec(): if not choice.exec():
return None return None
@@ -394,6 +422,7 @@ class Setting(QWidget):
"proxy_list": Config.global_config.get( "proxy_list": Config.global_config.get(
Config.global_config.update_ProxyUrlList Config.global_config.update_ProxyUrlList
), ),
"download_dict": version_remote["download_dict"],
"thread_numb": Config.global_config.get( "thread_numb": Config.global_config.get(
Config.global_config.update_ThreadNumb Config.global_config.update_ThreadNumb
), ),
@@ -461,12 +490,21 @@ class Setting(QWidget):
else: else:
time_local = datetime.strptime("2000-01-01 00:00", "%Y-%m-%d %H:%M") time_local = datetime.strptime("2000-01-01 00:00", "%Y-%m-%d %H:%M")
notice["notice_dict"] = {
"ALL~公告": "\n---\n".join(
[str(_) for _ in notice["notice_dict"].values() if isinstance(_, str)]
),
**notice["notice_dict"],
}
if if_show or ( if if_show or (
datetime.now() > datetime.strptime(notice["time"], "%Y-%m-%d %H:%M") datetime.now() > datetime.strptime(notice["time"], "%Y-%m-%d %H:%M")
and datetime.strptime(notice["time"], "%Y-%m-%d %H:%M") > time_local and datetime.strptime(notice["time"], "%Y-%m-%d %H:%M") > time_local
): ):
choice = NoticeMessageBox(self.window(), notice["notice_dict"]) choice = NoticeMessageBox(self.window(), "公告", notice["notice_dict"])
choice.button_cancel.hide()
choice.button_layout.insertStretch(0, 1)
if choice.exec(): if choice.exec():
with (Config.app_path / "resources/notice.json").open( with (Config.app_path / "resources/notice.json").open(
mode="w", encoding="utf-8" mode="w", encoding="utf-8"
@@ -960,3 +998,14 @@ def version_text(version_numb: list) -> str:
f"v{'.'.join(str(_) for _ in version_numb[0:3])}-beta.{version_numb[3]}" f"v{'.'.join(str(_) for _ in version_numb[0:3])}-beta.{version_numb[3]}"
) )
return version return version
def version_info_markdown(info: dict) -> str:
"""将版本信息字典转为markdown信息"""
version_info = ""
for key, value in info.items():
version_info += f"### {key}\n\n"
for v in value:
version_info += f"- {v}\n\n"
return version_info

View File

@@ -219,9 +219,10 @@ class DownloadManager(QDialog):
url_dict["官方镜像站"] = ( url_dict["官方镜像站"] = (
f"https://gitee.com/DLmaster_361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip" f"https://gitee.com/DLmaster_361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip"
) )
url_dict["官方下载站"] = ( for name, download_url_head in self.config["download_dict"].items():
f"https://jp-download.fearr.xyz/AUTO_MAA/AUTO_MAA_{version_text(self.main_version)}.zip" url_dict[name] = (
) f"{download_url_head}AUTO_MAA_{version_text(self.main_version)}.zip"
)
for proxy_url in self.config["proxy_list"]: for proxy_url in self.config["proxy_list"]:
url_dict[proxy_url] = ( url_dict[proxy_url] = (
f"{proxy_url}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip" f"{proxy_url}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip"
@@ -234,33 +235,36 @@ class DownloadManager(QDialog):
return f"https://jp-download.fearr.xyz/MAA/MAA-{version_text(self.main_version)}-win-x64.zip" return f"https://jp-download.fearr.xyz/MAA/MAA-{version_text(self.main_version)}-win-x64.zip"
if "selected" in self.config: if "selected" in self.config:
proxy_url = self.config["selected"] selected_url = self.config["selected"]
elif "speed_result" in self.config: elif "speed_result" in self.config:
proxy_url = max( selected_url = max(
self.config["speed_result"], key=self.config["speed_result"].get self.config["speed_result"], key=self.config["speed_result"].get
) )
if self.name == "AUTO_MAA主程序": if self.name == "AUTO_MAA主程序":
if proxy_url == "GitHub站": if selected_url == "GitHub站":
return f"https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip" return f"https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip"
elif proxy_url == "官方镜像站": elif selected_url == "官方镜像站":
return f"https://gitee.com/DLmaster_361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip" return f"https://gitee.com/DLmaster_361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip"
elif proxy_url == "官方下载站": elif selected_url in self.config["download_dict"].keys():
return f"https://jp-download.fearr.xyz/AUTO_MAA/AUTO_MAA_{version_text(self.main_version)}.zip" return f"{self.config["download_dict"][selected_url]}AUTO_MAA_{version_text(self.main_version)}.zip"
else: else:
return f"{proxy_url}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip" return f"{selected_url}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip"
elif self.name == "AUTO_MAA更新器": elif self.name == "AUTO_MAA更新器":
if proxy_url == "GitHub站": if selected_url == "GitHub站":
return f"https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/Updater_{version_text(self.updater_version)}.zip" return f"https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/Updater_{version_text(self.updater_version)}.zip"
elif proxy_url == "官方镜像站": elif selected_url == "官方镜像站":
return f"https://gitee.com/DLmaster_361/AUTO_MAA/releases/download/{version_text(self.main_version)}/Updater_{version_text(self.updater_version)}.zip" return f"https://gitee.com/DLmaster_361/AUTO_MAA/releases/download/{version_text(self.main_version)}/Updater_{version_text(self.updater_version)}.zip"
elif proxy_url == "官方下载站": elif selected_url in self.config["download_dict"].keys():
return f"https://jp-download.fearr.xyz/AUTO_MAA/Updater_{version_text(self.updater_version)}.zip" print(
f"{self.config["download_dict"][selected_url]}Updater_{version_text(self.updater_version)}.zip"
)
return f"{self.config["download_dict"][selected_url]}Updater_{version_text(self.updater_version)}.zip"
else: else:
return f"{proxy_url}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/Updater_{version_text(self.updater_version)}.zip" return f"{selected_url}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/Updater_{version_text(self.updater_version)}.zip"
def test_speed_task1(self) -> None: def test_speed_task1(self) -> None:
@@ -618,6 +622,7 @@ if __name__ == "__main__":
# 合并代理列表 # 合并代理列表
download_config = { download_config = {
"proxy_list": list(set(proxy_list + remote_proxy_list)), "proxy_list": list(set(proxy_list + remote_proxy_list)),
"download_dict": version_remote["download_dict"],
"thread_numb": thread_numb, "thread_numb": thread_numb,
} }

View File

@@ -1,14 +1,60 @@
{ {
"main_version": "4.2.5.5", "main_version": "4.2.5.6",
"updater_version": "1.2.0.0", "updater_version": "1.2.0.1",
"announcement": "\n## 新增功能\n- 屏蔽MuMu模拟器开屏广告功能上线\n- 更新器支持多线程下载\n- 添加强制关闭ADB与模拟器等增强任务项\n## 修复BUG\n- 修复统计信息HTML模板公招匹配错误\n- 修复密码显示按钮动画异常\n- 修复`检测到MAA未能实际执行任务`报错被异常屏蔽\n- 修复MAA超时判定异常失效\n## 程序优化\n- 关机等电源操作添加100s倒计时\n- 人工排查弹窗方法优化\n- 人工排查时自动屏蔽静默操作\n- 公告样式优化", "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.2.5.6":{
"程序优化": [
"更新信息样式优化",
"更新器支持动态获取下载站"
]
},
"4.2.5.5": {
"程序优化": [
"公告样式优化"
]
},
"4.2.5.4": {
"新增功能": [
"添加强制关闭ADB与模拟器等增强任务项"
],
"修复BUG": [
"修复`检测到MAA未能实际执行任务`报错被异常屏蔽",
"修复MAA超时判定异常失效"
]
},
"4.2.5.3": {
"程序优化": [
"关机等电源操作添加100s倒计时",
"人工排查弹窗方法优化",
"人工排查时自动屏蔽静默操作"
]
},
"4.2.5.2": {
"新增功能": [
"屏蔽MuMu模拟器开屏广告功能上线",
"更新器支持多线程下载"
],
"修复BUG": [
"修复密码显示按钮动画异常"
]
},
"4.2.5.1": {
"修复BUG": [
"修复统计信息HTML模板公招匹配错误"
]
}
},
"proxy_list": [ "proxy_list": [
"",
"https://gitproxy.click/", "https://gitproxy.click/",
"https://cdn.moran233.xyz/", "https://cdn.moran233.xyz/",
"https://gh.llkk.cc/", "https://gh.llkk.cc/",
"https://github.akams.cn/", "https://github.akams.cn/",
"https://www.ghproxy.cn/", "https://www.ghproxy.cn/",
"https://ghfast.top/" "https://ghfast.top/"
] ],
"download_dict": {
"官方下载站-jp": "https://jp-download.fearr.xyz/AUTO_MAA/",
"官方下载站-hw": "http://hwobs.fearr.xyz/releases/artifacts/"
}
} }