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 zip_data = resp.content
from models.dashboard import dashboard_manager from models.dashboard import dashboard_manager
ok = dashboard_manager.import_theme_zip(zip_data) 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} return {"ok": ok}
except Exception as e: except Exception as e:
return {"ok": False, "error": str(e)} return {"ok": False, "error": str(e)}
+6 -4
View File
@@ -1,10 +1,12 @@
{ {
"name": "TurboSu", "name": "TurboSu - 极速中枢",
"short_name": "TurboSu", "short_name": "TurboSu",
"description": "赛车遥测仪表盘", "description": "赛车遥测仪表盘",
"start_url": "/", "start_url": "/",
"display": "standalone", "display": "standalone",
"background_color": "#0a0a0f", "background_color": "#060a16",
"theme_color": "#0a0a0f", "theme_color": "#060a16",
"icons": [] "icons": [
{"src": "/static/img/logo.svg", "sizes": "any", "type": "image/svg+xml"}
]
} }