Add PWA support and mobile responsive layout
- PWA manifest, service worker (stale-while-revalidate for static assets, network-only for API), and app icons for installability - Root-scoped /manifest.json and /sw.js routes in FastAPI - New mobile.css with responsive breakpoints at 768/600/400px: fixed bottom tab bar on phones, single-column cards, full-screen modals, compact header toolbar, touch-friendly targets - Fix modal-content-wide min-width overflow on small screens - Update README with Camera, OpenRGB, and PWA features Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.responses import FileResponse, JSONResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from starlette.requests import Request
|
||||
@@ -248,6 +248,26 @@ app.add_middleware(
|
||||
# Include API routes
|
||||
app.include_router(router)
|
||||
|
||||
# PWA: serve manifest and service worker from root scope
|
||||
_static_root = Path(__file__).parent / "static"
|
||||
|
||||
|
||||
@app.get("/manifest.json", include_in_schema=False)
|
||||
async def pwa_manifest():
|
||||
"""Serve PWA manifest from root scope."""
|
||||
return FileResponse(_static_root / "manifest.json", media_type="application/manifest+json")
|
||||
|
||||
|
||||
@app.get("/sw.js", include_in_schema=False)
|
||||
async def pwa_service_worker():
|
||||
"""Serve service worker from root scope (controls all pages)."""
|
||||
return FileResponse(
|
||||
_static_root / "sw.js",
|
||||
media_type="application/javascript",
|
||||
headers={"Cache-Control": "no-cache"},
|
||||
)
|
||||
|
||||
|
||||
# Mount static files
|
||||
static_path = Path(__file__).parent / "static"
|
||||
if static_path.exists():
|
||||
|
||||
Reference in New Issue
Block a user