fix: 修复监控链路 api_key 未解码致 401、瞬时 401 误禁、前端表单多处问题 - monitor: 调度链路对 base64 存储的 api_key 解码(此前直接发送编码串导致所有账号 401) - fetcher: 401/403 先按重试次数确认再判定禁用,避免瞬时 401 误杀;POST 自动补 Content-Type: application/json - ui: val/err 兼容 # 前缀(保存无反应的根因);平台编辑回填 headers 反转义;监控页补添加账号入口 - test: 新增 monitor 解码回归测试,共 51 个用例

This commit is contained in:
2026-08-05 00:21:31 +08:00
parent 17d2496a65
commit edf19e121b
7 changed files with 132 additions and 13 deletions
+10
View File
@@ -8,6 +8,7 @@
from __future__ import annotations
import base64
import logging
import threading
import time
@@ -42,9 +43,18 @@ _ACCOUNT_SQL = """
"""
def _unb64(v: str) -> str:
"""api_key 以 base64 存储,内部使用时必须解码回明文。"""
try:
return base64.b64decode(v.encode("ascii")).decode("utf-8")
except Exception:
return v
def _split(row: dict) -> tuple[dict, dict]:
"""把 JOIN 行拆成 (account, platform) 两个 dict。"""
account = {k: row[k] for k in _ACCOUNT_FIELDS if k in row}
account["api_key"] = _unb64(account["api_key"])
platform = {k: row[k] for k in _PLATFORM_FIELDS if k in row}
platform["name"] = platform.pop("platform_name")
platform["id"] = platform.pop("platform_id")