fix: 统计卡片'安装失败'→'启动失败' + 合并 error_count 计数
This commit is contained in:
@@ -460,5 +460,27 @@
|
||||
"framework.command.execute"
|
||||
],
|
||||
"timestamp": 29166.973069289
|
||||
},
|
||||
"4dc1c6d5": {
|
||||
"plugin_name": "example_plugin",
|
||||
"permissions": [
|
||||
"plugin.example.read",
|
||||
"plugin.example.write",
|
||||
"plugin.example.execute",
|
||||
"framework.event.subscribe",
|
||||
"framework.command.execute"
|
||||
],
|
||||
"timestamp": 29386.796805455
|
||||
},
|
||||
"0dd80fb1": {
|
||||
"plugin_name": "sentinel",
|
||||
"permissions": [
|
||||
"plugin.sentinel.read",
|
||||
"plugin.sentinel.write",
|
||||
"plugin.network.access",
|
||||
"framework.event.subscribe",
|
||||
"framework.command.execute"
|
||||
],
|
||||
"timestamp": 29386.802027486
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ commands:
|
||||
permissions:
|
||||
- framework.command.test
|
||||
source: internal
|
||||
last_updated: 29166.959137102
|
||||
last_updated: 29386.77279457
|
||||
plugin_commands:
|
||||
example_plugin:
|
||||
echo: *id001
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
http_port: 4200
|
||||
last_updated: 29166.971388508
|
||||
last_updated: 29386.797962851
|
||||
plugin_routes:
|
||||
example_plugin:
|
||||
- methods:
|
||||
|
||||
@@ -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),
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<div class="stat-chip"><span class="stat-num" id="st-total">-</span> 总计</div>
|
||||
<div class="stat-chip loaded"><span class="stat-num" id="st-loaded">-</span> 已启用</div>
|
||||
<div class="stat-chip disabled"><span class="stat-num" id="st-disabled">-</span> 已停用</div>
|
||||
<div class="stat-chip failed"><span class="stat-num" id="st-failed">-</span> 安装失败</div>
|
||||
<div class="stat-chip failed"><span class="stat-num" id="st-failed">-</span> 启动失败</div>
|
||||
</div>
|
||||
|
||||
<!-- ── 导入区域 ── -->
|
||||
@@ -71,7 +71,7 @@
|
||||
var fd = document.getElementById("fail-detail");
|
||||
if (stats.fail_details && Object.keys(stats.fail_details).length) {
|
||||
fd.style.display = "block";
|
||||
fd.innerHTML = "<strong>安装失败:</strong> " + Object.entries(stats.fail_details).map(function(e){return e[0]+": "+esc(e[1])}).join(" | ");
|
||||
fd.innerHTML = "<strong>启动失败:</strong> " + Object.entries(stats.fail_details).map(function(e){return e[0]+": "+esc(e[1])}).join(" | ");
|
||||
} else fd.style.display = "none";
|
||||
|
||||
var r2 = await fetch("./api/plugins"), data = await r2.json();
|
||||
|
||||
Reference in New Issue
Block a user