From d0206121b1302150ff50277cd99c9eb1961d723c Mon Sep 17 00:00:00 2001 From: qinglong Date: Sat, 13 Jun 2026 18:44:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=9F=E8=AE=A1=E5=8D=A1=E7=89=87'?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=A4=B1=E8=B4=A5'=E2=86=92'=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=A4=B1=E8=B4=A5'=20+=20=E5=90=88=E5=B9=B6=20error?= =?UTF-8?q?=5Fcount=20=E8=AE=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/permissions/pending_requests.json | 22 ++++++++++++++++++++++ config/plugins/commands.yaml | 2 +- config/services/network_routes.yaml | 2 +- services/web_panel/routes/plugins.py | 10 ++++++++-- static/web_panel/pages/plugins.html | 4 ++-- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/config/permissions/pending_requests.json b/config/permissions/pending_requests.json index d70379c..ad987f5 100644 --- a/config/permissions/pending_requests.json +++ b/config/permissions/pending_requests.json @@ -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 } } \ No newline at end of file diff --git a/config/plugins/commands.yaml b/config/plugins/commands.yaml index fea5425..8305f77 100644 --- a/config/plugins/commands.yaml +++ b/config/plugins/commands.yaml @@ -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 diff --git a/config/services/network_routes.yaml b/config/services/network_routes.yaml index 4a0b563..ca444e7 100644 --- a/config/services/network_routes.yaml +++ b/config/services/network_routes.yaml @@ -1,5 +1,5 @@ http_port: 4200 -last_updated: 29166.971388508 +last_updated: 29386.797962851 plugin_routes: example_plugin: - methods: diff --git a/services/web_panel/routes/plugins.py b/services/web_panel/routes/plugins.py index 47f0122..7e75016 100644 --- a/services/web_panel/routes/plugins.py +++ b/services/web_panel/routes/plugins.py @@ -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), }) diff --git a/static/web_panel/pages/plugins.html b/static/web_panel/pages/plugins.html index 564b48e..7a12360 100644 --- a/static/web_panel/pages/plugins.html +++ b/static/web_panel/pages/plugins.html @@ -6,7 +6,7 @@
- 总计
- 已启用
- 已停用
-
- 安装失败
+
- 启动失败
@@ -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 = "安装失败: " + Object.entries(stats.fail_details).map(function(e){return e[0]+": "+esc(e[1])}).join(" | "); + fd.innerHTML = "启动失败: " + 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();