refactor: scenes use manifest.json (same structure as dashboards)

This commit is contained in:
2026-07-27 11:39:42 +08:00
parent 7a03fd3ebd
commit 16537a6f49
2 changed files with 15 additions and 15 deletions
+7 -7
View File
@@ -668,11 +668,11 @@ async def api_market_upload_scene(file: UploadFile = File(...), token: str = "")
try:
zip_data = await file.read()
with zipfile.ZipFile(io.BytesIO(zip_data), 'r') as zf:
if 'scene.json' not in zf.namelist():
return {"error": "缺少 scene.json"}
scene = _json.loads(zf.read('scene.json').decode('utf-8'))
if 'manifest.json' not in zf.namelist():
return {"error": "缺少 manifest.json"}
scene = _json.loads(zf.read('manifest.json').decode('utf-8'))
if not scene.get('name'):
return {"error": "scene.json 缺少 name"}
return {"error": "manifest.json 缺少 name"}
deps = set()
for canvas in scene.get('canvases', []):
for p in canvas.get('placements', []):
@@ -712,8 +712,8 @@ async def api_market_install_scene(id: str = "", filename: str = ""):
zip_data = resp.content
missing = []
with zipfile.ZipFile(io.BytesIO(zip_data), 'r') as zf:
if 'scene.json' in zf.namelist():
scene = _json.loads(zf.read('scene.json').decode('utf-8'))
if 'manifest.json' in zf.namelist():
scene = _json.loads(zf.read('manifest.json').decode('utf-8'))
from models.dashboard import dashboard_manager
for canvas in scene.get('canvases', []):
for p in canvas.get('placements', []):
@@ -788,7 +788,7 @@ async def api_market_publish_local(data: dict):
buf = io.BytesIO()
with zipfile.ZipFile(buf, 'w', zipfile.ZIP_DEFLATED) as zf:
zf.writestr("scene.json", _json.dumps(scene, indent=2, ensure_ascii=False))
zf.writestr("manifest.json", _json.dumps(scene, indent=2, ensure_ascii=False))
zip_data = buf.getvalue()
cfg = get_config()