feat(core): 接入镜像源

This commit is contained in:
DLmaster
2025-02-17 18:06:05 +08:00
parent 8e3026f91e
commit fcf61fd39a
7 changed files with 130 additions and 25 deletions

View File

@@ -151,3 +151,12 @@ jobs:
gh release create "$TAGNAME" --target "main" --title "$NAME" --notes "$NOTES" artifacts/* gh release create "$TAGNAME" --target "main" --title "$NAME" --notes "$NOTES" artifacts/*
env: env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
- name: Setup SSH Key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
- name: Upload Release to Server
run: |
scp -r artifacts/* ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:/home/user/files/AUTO_MAA/

View File

@@ -151,14 +151,12 @@ jobs:
gh release create "$TAGNAME" --target "main" --title "$NAME" --notes "$NOTES" --prerelease artifacts/* gh release create "$TAGNAME" --target "main" --title "$NAME" --notes "$NOTES" --prerelease artifacts/*
env: env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
- name: Setup SSH Key - name: Setup SSH Key
run: | run: |
mkdir -p ~/.ssh mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
- 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/

View File

@@ -82,6 +82,8 @@ MAA多账号管理与自动化软件
![Alt](https://repobeats.axiom.co/api/embed/6c2f834141eff1ac297db70d12bd11c6236a58a5.svg "Repobeats analytics image") ![Alt](https://repobeats.axiom.co/api/embed/6c2f834141eff1ac297db70d12bd11c6236a58a5.svg "Repobeats analytics image")
感谢 @ClozyA 为本项目提供的下载服务器
## Star History ## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=DLmaster361/AUTO_MAA&type=Date)](https://star-history.com/#DLmaster361/AUTO_MAA&Date) [![Star History Chart](https://api.star-history.com/svg?repos=DLmaster361/AUTO_MAA&type=Date)](https://star-history.com/#DLmaster361/AUTO_MAA&Date)

View File

@@ -50,6 +50,8 @@ from qfluentwidgets import (
PushSettingCard, PushSettingCard,
) )
from PySide6.QtCore import Qt from PySide6.QtCore import Qt
import requests
import time
from functools import partial from functools import partial
from pathlib import Path from pathlib import Path
from typing import List from typing import List
@@ -59,6 +61,7 @@ import shutil
from app.core import Config, MainInfoBar, TaskManager from app.core import Config, MainInfoBar, TaskManager
from app.services import Crypto from app.services import Crypto
from app.utils import Updater
from .Widget import ( from .Widget import (
LineEditMessageBox, LineEditMessageBox,
LineEditSettingCard, LineEditSettingCard,
@@ -108,14 +111,21 @@ class MemberManager(QWidget):
] ]
) )
self.tools.addSeparator() self.tools.addSeparator()
self.key = Action( self.tools.addAction(
Action(
FluentIcon.DOWNLOAD,
"脚本下载器",
triggered=self.member_downloader,
)
)
self.tools.addSeparator()
self.tools.addAction(
Action(
FluentIcon.HIDE, FluentIcon.HIDE,
"显示/隐藏密码", "显示/隐藏密码",
checkable=True, checkable=True,
triggered=self.show_password, triggered=self.show_password,
) )
self.tools.addAction(
self.key,
) )
layout.addWidget(self.tools) layout.addWidget(self.tools)
@@ -292,6 +302,64 @@ class MemberManager(QWidget):
self.member_manager.show_SettingBox(index + 1) self.member_manager.show_SettingBox(index + 1)
def member_downloader(self):
"""脚本下载器"""
choice = ComboBoxMessageBox(
self.window(),
"选择一个脚本类型以下载相应脚本",
["选择脚本类型"],
[["MAA"]],
)
if choice.exec() and choice.input[0].currentIndex() != -1:
if choice.input[0].currentText() == "MAA":
folder = QFileDialog.getExistingDirectory(
self, "选择MAA下载目录", str(Config.app_path)
)
if not folder:
logger.warning("选择MAA下载目录时未选择文件夹")
MainInfoBar.push_info_bar(
"warning", "警告", "未选择MAA下载目录", 5000
)
return None
# 从mirrorc服务器获取最新版本信息
for _ in range(3):
try:
response = requests.get(
"https://mirrorc.top/api/resources/MAA/latest?user_agent=MaaWpfGui&os=win&arch=x64&channel=beta"
)
maa_info = response.json()
break
except Exception as e:
err = e
time.sleep(0.1)
else:
choice = MessageBox(
"错误",
f"获取版本信息时出错:\n{err}",
self.window(),
)
choice.cancelButton.hide()
choice.buttonLayout.insertStretch(1)
if choice.exec():
return None
maa_version = list(
map(
int,
maa_info["data"]["version_name"][1:]
.replace("-beta", "")
.split("."),
)
)
while len(maa_version) < 4:
maa_version.append(0)
self.downloader = Updater(Path(folder), "MAA", maa_version, [])
self.downloader.ui.show()
def show_password(self): def show_password(self):
if Config.PASSWORD == "": if Config.PASSWORD == "":

View File

@@ -363,7 +363,7 @@ class Setting(QWidget):
def show_notice(self, if_show: bool = True): def show_notice(self, if_show: bool = True):
"""显示公告""" """显示公告"""
# 从远程服务器获取最新版本信息 # 从远程服务器获取最新公告
for _ in range(3): for _ in range(3):
try: try:
response = requests.get( response = requests.get(

View File

@@ -70,7 +70,7 @@ class UpdateProcess(QThread):
self.name = name self.name = name
self.main_version = main_version self.main_version = main_version
self.updater_version = updater_version self.updater_version = updater_version
self.download_path = app_path / "AUTO_MAA_Update.zip" # 临时下载文件的路径 self.download_path = app_path / "DOWNLOAD_TEMP.zip" # 临时下载文件的路径
self.version_path = app_path / "resources/version.json" self.version_path = app_path / "resources/version.json"
def run(self) -> None: def run(self) -> None:
@@ -160,7 +160,7 @@ class UpdateProcess(QThread):
zip_ref.extractall(self.app_path) zip_ref.extractall(self.app_path)
break break
except PermissionError: except PermissionError:
self.info.emit("解压出错:AUTO_MAA正在运行,正在等待其关闭") self.info.emit(f"解压出错:{self.name}正在运行,正在等待其关闭")
time.sleep(1) time.sleep(1)
self.info.emit("正在删除临时文件") self.info.emit("正在删除临时文件")
@@ -178,12 +178,15 @@ class UpdateProcess(QThread):
return None return None
# 更新version文件 # 更新version文件
if self.name in ["AUTO_MAA主程序", "AUTO_MAA更新器"]:
with open(self.version_path, "r", encoding="utf-8") as f: with open(self.version_path, "r", encoding="utf-8") as f:
version_info = json.load(f) version_info = json.load(f)
if self.name == "AUTO_MAA更新器": if self.name == "AUTO_MAA主程序":
version_info["updater_version"] = ".".join(map(str, self.updater_version))
elif self.name == "AUTO_MAA主程序":
version_info["main_version"] = ".".join(map(str, self.main_version)) version_info["main_version"] = ".".join(map(str, self.main_version))
elif self.name == "AUTO_MAA更新器":
version_info["updater_version"] = ".".join(
map(str, self.updater_version)
)
with open(self.version_path, "w", encoding="utf-8") as f: with open(self.version_path, "w", encoding="utf-8") as f:
json.dump(version_info, f, ensure_ascii=False, indent=4) json.dump(version_info, f, ensure_ascii=False, indent=4)
@@ -194,6 +197,12 @@ class UpdateProcess(QThread):
shell=True, shell=True,
creationflags=subprocess.CREATE_NO_WINDOW, creationflags=subprocess.CREATE_NO_WINDOW,
) )
elif self.name == "MAA":
subprocess.Popen(
str(self.app_path / "MAA.exe"),
shell=True,
creationflags=subprocess.CREATE_NO_WINDOW,
)
self.accomplish.emit() self.accomplish.emit()
@@ -239,6 +248,9 @@ class UpdateProcess(QThread):
url_list.append( url_list.append(
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_list.append(
f"https://jp-download.fearr.xyz/AUTO_MAA/AUTO_MAA_{version_text(self.main_version)}.zip"
)
for i in range(len(PROXY_list)): for i in range(len(PROXY_list)):
url_list.append( url_list.append(
f"{PROXY_list[i]}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip" f"{PROXY_list[i]}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip"
@@ -247,10 +259,21 @@ class UpdateProcess(QThread):
url_list.append( url_list.append(
f"https://gitee.com/DLmaster_361/AUTO_MAA/releases/download/{version_text(self.main_version)}/Updater_{version_text(self.updater_version)}.zip" f"https://gitee.com/DLmaster_361/AUTO_MAA/releases/download/{version_text(self.main_version)}/Updater_{version_text(self.updater_version)}.zip"
) )
url_list.append(
f"https://jp-download.fearr.xyz/AUTO_MAA/Updater_{version_text(self.updater_version)}.zip"
)
for i in range(len(PROXY_list)): for i in range(len(PROXY_list)):
url_list.append( url_list.append(
f"{PROXY_list[i]}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/Updater_{version_text(self.updater_version)}.zip" f"{PROXY_list[i]}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/Updater_{version_text(self.updater_version)}.zip"
) )
elif self.name == "MAA":
url_list.append(
f"https://jp-download.fearr.xyz/MAA/MAA-{version_text(self.main_version)}-win-x64.zip"
)
for i in range(len(PROXY_list)):
url_list.append(
f"{PROXY_list[i]}https://github.com/MaaAssistantArknights/MaaAssistantArknights/releases/download/{version_text(self.main_version)}/MAA-{version_text(self.main_version)}-win-x64.zip"
)
return url_list return url_list
@@ -265,7 +288,12 @@ class Updater(QObject):
self.ui.setWindowTitle("AUTO_MAA更新器") self.ui.setWindowTitle("AUTO_MAA更新器")
self.ui.resize(700, 70) self.ui.resize(700, 70)
self.ui.setWindowIcon( self.ui.setWindowIcon(
QIcon(str(app_path / "resources/icons/AUTO_MAA_Updater.ico")) QIcon(
str(
Path(sys.argv[0]).resolve().parent
/ "resources/icons/AUTO_MAA_Updater.ico"
)
)
) )
# 创建垂直布局 # 创建垂直布局

View File

@@ -1,7 +1,7 @@
{ {
"main_version": "4.2.3.4", "main_version": "4.2.4.0",
"updater_version": "1.1.1.3", "updater_version": "1.1.2.0",
"announcement": "\n## 新增功能\n- 添加`简洁用户列表下相邻两个任务间的切换方式`可选项\n- 恢复启动后直接运行主任务功能以及相关托盘菜单\n## 修复BUG\n- 修复静默代理标记移除异常情况\n- 适配深色模式 #18\n## 程序优化\n- 优化MAA关闭方法\n- 添加高级代理文件校验过程\n- 升级日志监看方法\n- 优化主调度台默认选项\n- 配置MAA前关闭可能未正常退出的MAA进程", "announcement": "\n## 新增功能\n- 添加`简洁用户列表下相邻两个任务间的切换方式`可选项\n- 恢复启动后直接运行主任务功能以及相关托盘菜单\n## 修复BUG\n- 修复静默代理标记移除异常情况\n- 适配深色模式 #18\n## 程序优化\n- 优化MAA关闭方法\n- 添加高级代理文件校验过程\n- 升级日志监看方法\n- 优化主调度台默认选项\n- 配置MAA前关闭可能未正常退出的MAA进程\n- 接入镜像源",
"proxy_list": [ "proxy_list": [
"", "",
"https://gitproxy.click/", "https://gitproxy.click/",