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": []}