Merge branch 'user_list_dev' into dev

This commit is contained in:
DLmaster
2025-03-21 22:48:57 +08:00
4 changed files with 78 additions and 36 deletions

View File

@@ -52,6 +52,8 @@ from typing import Union, Dict, List, Tuple
class AppConfig:
VERSION = "4.2.5.7"
def __init__(self) -> None:
self.app_path = Path(sys.argv[0]).resolve().parent # 获取软件根目录
@@ -86,7 +88,7 @@ class AppConfig:
# 生成版本信息文件
if not self.version_path.exists():
version = {
"main_version": "0.0.0.0",
"main_version": self.VERSION,
"updater_version": "0.0.0.0",
}
with self.version_path.open(mode="w", encoding="utf-8") as f:
@@ -122,7 +124,7 @@ class AppConfig:
)
logger.info("===================================")
logger.info("AUTO_MAA 主程序")
logger.info("版本号: v4.2.5.4")
logger.info(f"版本号: v{self.VERSION}")
logger.info(f"根目录: {self.app_path}")
logger.info("===================================")

View File

@@ -273,9 +273,7 @@ class Setting(QWidget):
version_current: Dict[
str, Union[str, Dict[str, Union[str, Dict[str, List[str]]]]]
] = json.load(f)
main_version_current = list(
map(int, version_current["main_version"].split("."))
)
main_version_current = list(map(int, Config.VERSION.split(".")))
updater_version_current = list(
map(int, version_current["updater_version"].split("."))
)
@@ -409,6 +407,12 @@ class Setting(QWidget):
def update_main(self) -> None:
"""更新主程序"""
with Config.version_path.open(mode="r", encoding="utf-8") as f:
version_info = json.load(f)
version_info["main_version"] = Config.VERSION
with Config.version_path.open(mode="w", encoding="utf-8") as f:
json.dump(version_info, f, ensure_ascii=False, indent=4)
subprocess.Popen(
str(Config.app_path / "Updater.exe"),
shell=True,

View File

@@ -146,6 +146,45 @@ class DownloadProcess(QThread):
self.accomplish.emit(0)
class ZipExtractProcess(QThread):
"""解压子线程"""
info = Signal(str)
accomplish = Signal()
def __init__(self, name: str, app_path: Path, download_path: Path) -> None:
super(ZipExtractProcess, self).__init__()
self.name = name
self.app_path = app_path
self.download_path = download_path
def run(self) -> None:
try:
while True:
if self.isInterruptionRequested():
self.download_path.unlink()
return None
try:
with zipfile.ZipFile(self.download_path, "r") as zip_ref:
zip_ref.extractall(self.app_path)
self.accomplish.emit()
break
except PermissionError:
self.info.emit(f"解压出错:{self.name}正在运行,正在等待其关闭")
time.sleep(1)
except Exception as e:
e = str(e)
e = "\n".join([e[_ : _ + 75] for _ in range(0, len(e), 75)])
self.info.emit(f"解压更新时出错:\n{e}")
return None
class DownloadManager(QDialog):
"""下载管理器"""
@@ -179,7 +218,7 @@ class DownloadManager(QDialog):
self.setWindowIcon(
QIcon(str(app_path / "resources/icons/AUTO_MAA_Updater.ico"))
)
self.setFixedSize(700, 70)
self.resize(700, 70)
setTheme(Theme.AUTO, lazy=True)
@@ -448,37 +487,24 @@ class DownloadManager(QDialog):
outfile.write(infile.read())
self.download_path.with_suffix(f".part{i}").unlink()
# # 解压
try:
self.update_info("正在解压更新文件")
self.update_progress(0, 0, 0)
while True:
if self.isInterruptionRequested:
self.download_path.unlink()
return None
try:
self.update_info("正在解压更新文件")
self.update_progress(0, 0, 0)
with zipfile.ZipFile(self.download_path, "r") as zip_ref:
zip_ref.extractall(self.app_path)
break
except PermissionError:
self.info.emit(f"解压出错:{self.name}正在运行,正在等待其关闭")
time.sleep(1)
# 创建解压线程
self.zip_extract = ZipExtractProcess(
self.name, self.app_path, self.download_path
)
self.zip_loop = QEventLoop()
self.zip_extract.info.connect(self.update_info)
self.zip_extract.accomplish.connect(self.zip_loop.quit)
self.zip_extract.start()
self.zip_loop.exec()
self.update_info("正在删除临时文件")
self.update_progress(0, 0, 0)
self.update_info("正在删除临时文件")
self.update_progress(0, 0, 0)
if self.download_path.exists():
self.download_path.unlink()
self.update_info(f"{self.name}更新成功!")
self.update_progress(0, 100, 100)
except Exception as e:
e = str(e)
e = "\n".join([e[_ : _ + 75] for _ in range(0, len(e), 75)])
self.update_info(f"解压更新时出错:\n{e}")
return None
# 更新version文件
if not self.isInterruptionRequested and self.name in [
"AUTO_MAA主程序",
@@ -509,6 +535,8 @@ class DownloadManager(QDialog):
creationflags=subprocess.CREATE_NO_WINDOW,
)
self.update_info(f"{self.name}更新成功!")
self.update_progress(0, 100, 100)
self.download_accomplish.emit()
def update_info(self, text: str) -> None:
@@ -529,6 +557,12 @@ class DownloadManager(QDialog):
self.isInterruptionRequested = True
if hasattr(self, "zip_extract") and self.zip_extract:
self.zip_extract.requestInterruption()
if hasattr(self, "zip_loop") and self.zip_loop:
self.zip_loop.quit()
for process in self.download_process_dict.values():
process.requestInterruption()

View File

@@ -1,6 +1,6 @@
{
"main_version": "4.2.5.7",
"updater_version": "1.2.0.1",
"updater_version": "1.2.0.2",
"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.7":{
@@ -8,10 +8,12 @@
"添加每周剿灭模式上限功能"
],
"修复BUG": [
"修复更新通知阻碍调度开始问题 #32"
"修复更新通知阻碍调度开始问题 #32",
"修复更新器解压失败问题"
],
"程序优化": [
"打包流程删除无用过程"
"打包流程删除无用过程",
"主程序版本号完全写死在代码内部"
]
},
"4.2.5.6":{