Merge commit '75b06ca770ebcee68bf05ab95f069c6e8fd0cae8' into dev

This commit is contained in:
DLmaster361
2025-07-15 18:15:48 +08:00
4 changed files with 35 additions and 22 deletions

View File

@@ -1509,6 +1509,20 @@ class AppConfig(GlobalConfig):
return if_six_star
def save_general_log(self, log_path: Path, logs: list, general_result: str) -> None:
"""保存通用日志并生成对应统计数据"""
data: Dict[str, str] = {"general_result": general_result}
# 保存日志
log_path.parent.mkdir(parents=True, exist_ok=True)
with log_path.with_suffix(".log").open("w", encoding="utf-8") as f:
f.writelines(logs)
with log_path.with_suffix(".json").open("w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=4)
logger.info(f"处理完成:{log_path}")
def merge_statistic_info(self, statistic_path_list: List[Path]) -> dict:
"""合并指定数据统计信息文件"""
@@ -1535,7 +1549,7 @@ class AppConfig(GlobalConfig):
data[key][star_level] += count
# 合并掉落统计
if key == "drop_statistics":
elif key == "drop_statistics":
for stage, drops in single_data[key].items():
if stage not in data[key]:
@@ -1547,8 +1561,8 @@ class AppConfig(GlobalConfig):
data[key][stage][item] = 0
data[key][stage][item] += count
# 录入MAA结果
if key == "maa_result":
# 录入运行结果
elif key in ["maa_result", "general_result"]:
actual_date = datetime.strptime(
f"{json_file.parent.parent.name} {json_file.stem}",
@@ -1571,7 +1585,7 @@ class AppConfig(GlobalConfig):
data["index"][actual_date] = [
actual_date.strftime("%d%H:%M:%S"),
("完成" if single_data["maa_result"] == "Success!" else "异常"),
("完成" if single_data[key] == "Success!" else "异常"),
json_file,
]

View File

@@ -1903,15 +1903,17 @@ class MaaManager(QObject):
# 生成文本通知内容
formatted = []
for stage, items in message["drop_statistics"].items():
formatted.append(f"掉落统计({stage}:")
for item, quantity in items.items():
formatted.append(f" {item}: {quantity}")
if "drop_statistics" in message:
for stage, items in message["drop_statistics"].items():
formatted.append(f"掉落统计({stage}:")
for item, quantity in items.items():
formatted.append(f" {item}: {quantity}")
drop_text = "\n".join(formatted)
formatted = ["招募统计:"]
for star, count in message["recruit_statistics"].items():
formatted.append(f" {star}: {count}")
if "recruit_statistics" in message:
for star, count in message["recruit_statistics"].items():
formatted.append(f" {star}: {count}")
recruit_text = "\n".join(formatted)
message_text = (

View File

@@ -224,7 +224,6 @@ class GeneralManager(QObject):
logger.info(f"{self.name} | 开始代理配置: {sub[0]}")
sub_logs_list = []
sub_start_time = datetime.now()
run_book = False
@@ -378,20 +377,15 @@ class GeneralManager(QObject):
Path(sub_data["Info"]["ScriptAfterTask"]), "脚本后任务"
)
# # 保存运行日志以及统计信息
# Config.save_maa_log(
# Config.app_path
# / f"history/{curdate}/{sub_data['Info']['Name']}/{start_time.strftime("%H-%M-%S")}.log",
# self.check_script_log(start_time, mode_book[mode]),
# self.maa_result,
# )
sub_logs_list.append(
# 保存运行日志以及统计信息
Config.save_general_log(
Config.app_path
/ f"history/{curdate}/{sub_data['Info']['Name']}/{start_time.strftime("%H-%M-%S")}.json",
/ f"history/{curdate}/{sub_data['Info']['Name']}/{start_time.strftime("%H-%M-%S")}.log",
self.check_script_log(start_time),
self.script_result,
)
# 发送统计信息
# statistics = Config.merge_maa_logs("指定项", sub_logs_list)
statistics = {
"sub_index": sub[2],
"sub_info": sub[0],
@@ -658,7 +652,7 @@ class GeneralManager(QObject):
else:
for error_sign in self.error_log:
if error_sign in log:
self.script_result = error_sign
self.script_result = f"异常日志:{error_sign}"
break
else:
if self.script_process_manager.is_running():

View File

@@ -2,6 +2,9 @@
"main_version": "4.4.0.0",
"version_info": {
"4.4.0.0": {
"新增功能": [
"通用配置模式接入日志系统"
],
"修复BUG": [
"信任系统证书,并添加网络代理地址配置项 #50",
"适配 MAA 任务及基建设施日志翻译"