This commit is contained in:
xsxx03-art
2026-06-16 20:31:34 +08:00
parent 5db13a7d69
commit 944bc26fb9
21 changed files with 356 additions and 87 deletions
+10 -2
View File
@@ -913,10 +913,18 @@ def getLib():
@app.route('/api/component/<component_name>')
@login_required_json
def getComp(component_name):
"""Return component YAML data."""
data = readCompYaml(component_name, pdk_root_for_request_project())
"""Return component YAML data with injected category."""
comps_root = pdk_root_for_request_project()
data = readCompYaml(component_name, comps_root)
if data is None:
return jsonify({"error": "Component not found"}), 404
# Derive the category (parent folder name) for icon resolution on the canvas.
if isinstance(data, dict) and '__category__' not in data:
search_root = comps_root or current_pdk_root()
for root, dirs, files in os.walk(search_root):
if os.path.basename(root) == component_name:
data['__category__'] = os.path.basename(os.path.dirname(root))
break
return jsonify(data)
@app.route('/api/component/<component_name>/image')