From 27063e511768680dcf0c2430f2253dbf8c7b6b0a Mon Sep 17 00:00:00 2001 From: jingrow Date: Mon, 3 Nov 2025 02:56:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=B8=82=E5=9C=BA=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=A1=B5=E5=92=8C=E8=AF=A6=E6=83=85=E9=A1=B5=EF=BC=8C?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E8=8A=82=E7=82=B9=E5=B7=B2=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E5=B0=B1=E6=98=BE=E7=A4=BA=E6=9B=B4=E6=96=B0=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/jingrow/frontend/src/locales/zh-CN.json | 1 + .../src/views/dev/NodeMarketplace.vue | 3 +- apps/jingrow/jingrow/api/node_management.py | 35 ++++++++++++------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/apps/jingrow/frontend/src/locales/zh-CN.json b/apps/jingrow/frontend/src/locales/zh-CN.json index bce0b3b..b143be5 100644 --- a/apps/jingrow/frontend/src/locales/zh-CN.json +++ b/apps/jingrow/frontend/src/locales/zh-CN.json @@ -896,6 +896,7 @@ "Team": "开发团队", "Repository": "仓库", "Install": "安装", + "Update": "更新", "Loading applications...": "正在加载应用...", "No applications found": "未找到应用", "View details feature coming soon": "查看详情功能即将推出", diff --git a/apps/jingrow/frontend/src/views/dev/NodeMarketplace.vue b/apps/jingrow/frontend/src/views/dev/NodeMarketplace.vue index 5162a64..5b38642 100644 --- a/apps/jingrow/frontend/src/views/dev/NodeMarketplace.vue +++ b/apps/jingrow/frontend/src/views/dev/NodeMarketplace.vue @@ -370,7 +370,8 @@ async function loadInstalledNodes() { const response = await axios.get('/jingrow/installed-node-types') if (response.data.success) { const nodeTypes = response.data.node_types || [] - installedNodeTypes.value = new Set(nodeTypes) + // 存储为小写以便不区分大小写匹配 + installedNodeTypes.value = new Set(nodeTypes.map((t: string) => t.toLowerCase())) } } catch (error) { console.error('Load installed nodes error:', error) diff --git a/apps/jingrow/jingrow/api/node_management.py b/apps/jingrow/jingrow/api/node_management.py index 143df68..c55d297 100644 --- a/apps/jingrow/jingrow/api/node_management.py +++ b/apps/jingrow/jingrow/api/node_management.py @@ -303,23 +303,34 @@ async def check_node_exists(node_type: str): @router.get("/jingrow/installed-node-types") async def get_installed_node_types(): - """获取已安装的节点类型列表""" + """ + 获取已安装的节点类型列表 + 通过扫描节点目录获取,这是最高效的方式(只需要列出目录名,不需要读取文件) + """ try: - result = get_record_list( - pagetype="Local Ai Node", - fields=["node_type"], - filters=[], - limit_page_length=1000 - ) + # 确定节点目录路径:apps/jingrow/jingrow/ai/nodes + current_file = Path(__file__).resolve() + jingrow_root = current_file.parents[1] # jingrow + nodes_root = jingrow_root / "ai" / "nodes" - if result.get("success"): - records = result.get("data", {}).get("data", []) - node_types = [record.get("node_type") for record in records if record.get("node_type")] - return {"success": True, "node_types": node_types} - else: + node_types = [] + + # 如果目录不存在,返回空列表 + if not nodes_root.exists(): return {"success": True, "node_types": []} + + # 扫描目录,只获取目录名(最高效的方式) + for item in nodes_root.iterdir(): + if item.is_dir() and not item.name.startswith('.') and item.name != '__pycache__': + # 验证是否包含节点定义文件(可选,但更可靠) + json_file = item / f"{item.name}.json" + if json_file.exists(): + node_types.append(item.name) + + return {"success": True, "node_types": sorted(node_types)} except Exception as e: logger.error(f"获取已安装节点类型失败: {str(e)}") + logger.error(f"Traceback: {traceback.format_exc()}") return {"success": True, "node_types": []}