feat: 平台自动同步代码内置 provider,移除手动添加/删除平台 - 启动时 sync_platforms:注册表中的 provider 自动生成为平台记录 - 前端移除添加平台按钮与删除入口,平台列表只读 + 停用/启用 + 监控参数编辑 - 平台编辑表单仅保留间隔/重试/超时/备注(提供方锁定) - 测试更新:内置平台自动同步用例,共 93 个

This commit is contained in:
2026-08-05 07:37:30 +08:00
parent bdeb353bc2
commit 86ef5aa412
5 changed files with 52 additions and 51 deletions
+25
View File
@@ -75,5 +75,30 @@ def init_db() -> None:
conn.executescript(SCHEMA)
def sync_platforms() -> None:
"""把代码内置的 provider 自动同步为平台记录(缺失时创建)。
平台 = 代码注册表,无需用户手动添加;删除也会在下一次启动时重建。
"""
from app.providers import list_providers
with get_conn() as conn:
existing = {
r["provider_id"]
for r in conn.execute(
"SELECT provider_id FROM platforms WHERE provider_id != ''"
).fetchall()
}
for p in list_providers():
if p["id"] in existing:
continue
conn.execute(
"INSERT INTO platforms (provider_id, name, currency, icon, enabled) "
"VALUES (?, ?, ?, ?, 1)",
(p["id"], p["name"], p["currency"], p["icon"]),
)
existing.add(p["id"])
def rows_to_dicts(rows: list[sqlite3.Row]) -> list[dict]:
return [dict(r) for r in rows]