feat: PWA icon + download count increment on market install

This commit is contained in:
2026-07-26 21:43:14 +08:00
parent 98440099a8
commit 59887d7d46
2 changed files with 21 additions and 4 deletions
+15
View File
@@ -606,6 +606,21 @@ async def api_market_install(id: str = "", filename: str = ""):
zip_data = resp.content
from models.dashboard import dashboard_manager
ok = dashboard_manager.import_theme_zip(zip_data)
if ok:
try:
async with httpx.AsyncClient(timeout=5) as client2:
# Get current downloads
r = await client2.get(f"{url}/api/collections/dashboards/records/{id}")
current = r.json().get("downloads", 0) or 0
# Increment
await client2.patch(
f"{url}/api/collections/dashboards/records/{id}",
json={"downloads": current + 1}
)
except Exception:
pass
return {"ok": ok}
except Exception as e:
return {"ok": False, "error": str(e)}