节点市场列表页和详情页,如果节点已存在就显示更新按钮

This commit is contained in:
jingrow 2025-11-03 02:56:00 +08:00
parent f788a9948d
commit 27063e5117
3 changed files with 26 additions and 13 deletions

View File

@ -896,6 +896,7 @@
"Team": "开发团队",
"Repository": "仓库",
"Install": "安装",
"Update": "更新",
"Loading applications...": "正在加载应用...",
"No applications found": "未找到应用",
"View details feature coming soon": "查看详情功能即将推出",

View File

@ -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)

View File

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