fix: 统计卡片'安装失败'→'启动失败' + 合并 error_count 计数

This commit is contained in:
qinglong
2026-06-13 18:44:20 +08:00
parent e16250c7e7
commit d0206121b1
5 changed files with 34 additions and 6 deletions
+8 -2
View File
@@ -55,15 +55,21 @@ async def plugin_stats(req):
sm = req.app.get("service_manager")
ps = sm.get_service("plugin") if sm else None
total = len(ps.plugin_info) if ps else 0
loaded = len(ps.plugins) if ps else 0
loaded = sum(1 for n, info in ps.plugin_info.items() if n in ps.plugins) if ps else 0
disabled = total - loaded
# 启动失败: 插件目录存在但未成功加载 + 导入失败记录
failed = len(_IMPORT_FAILS)
if ps:
for name, info in ps.plugin_info.items():
if getattr(info, "error_count", 0) > 0 and name not in _IMPORT_FAILS:
failed += 1
_IMPORT_FAILS[name] = f"启动失败 (错误数: {info.error_count})"
return web.json_response({
"total": total,
"loaded": loaded,
"disabled": max(0, disabled),
"failed": failed,
"fail_details": _IMPORT_FAILS,
"fail_details": dict(_IMPORT_FAILS),
})