临时提交

This commit is contained in:
2025-09-20 21:57:37 +08:00
parent bfdf684952
commit 8f290cf610
25 changed files with 343 additions and 87 deletions

View File

@@ -336,6 +336,7 @@ class AiUtils(object):
screen_h = cls.parse_float(app[0], 'height', 736.0) if app else 736.0
# ---------- 主容器探测(评分选择最像聊天区的容器) ----------
def pick_container():
cands = []
for xp, ctype in (
@@ -706,7 +707,7 @@ class AiUtils(object):
data.extend(to_add)
cls._write_json_list(file_path, data)
LogManager.method_info(f"写入的路径是:{file_path}", "写入数据")
# LogManager.method_info(f"写入的路径是:{file_path}", "写入数据")
LogManager.info(f"[acList] 已追加 {len(to_add)} 条,当前总数={len(data)} -> {file_path}")
@@ -842,24 +843,25 @@ class AiUtils(object):
ids.append(str(it["anchorId"]))
return ids
@classmethod
def delete_anchors_by_ids(cls, ids: list[str], filename="log/acList.json") -> int:
def delete_anchors_by_ids(cls, ids: list[str], filename: str = "acList.json") -> int:
"""
根据 anchorId 列表根目录/log/acList.json 中删除匹配的 anchor。
返回删除数量。
根据 anchorId 列表,从项目根目录/log/acList.json 中删除匹配的 anchor。
- ids: 要删除的 anchorId 列表
- filename: 默认为 acList.json可以传文件名或绝对路径
返回:删除数量
"""
# 确保路径固定在根目录下的 log 文件夹
# 计算文件路径
root_dir = Path(__file__).resolve().parent.parent
file_path = root_dir / "log" / filename
if Path(filename).is_absolute():
file_path = Path(filename)
else:
file_path = root_dir / "log" / filename
if not file_path.exists():
return 0
# 读取 JSON 文件
try:
with open(file_path, "r", encoding="utf-8") as f:
data = json.load(f)
@@ -870,10 +872,12 @@ class AiUtils(object):
return 0
before = len(data)
# 保留不在 ids 里的对象
data = [d for d in data if isinstance(d, dict) and d.get("anchorId") not in ids]
deleted = before - len(data)
# 写回 JSON 文件
try:
file_path.parent.mkdir(parents=True, exist_ok=True)
with open(file_path, "w", encoding="utf-8") as f: