diff --git a/CHANGELOG.md b/CHANGELOG.md index dc9b9a3a6..6834d93c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ ### Features - 增加 `i18n` 支持,目前支持 `zh-CN` 和 `en-US`。 +- 增加 pwa 支持。 - 增加 RSS 管理页面。 - 增加搜索顶栏。 diff --git a/backend/src/main.py b/backend/src/main.py index 7a08865e8..4638f9f27 100644 --- a/backend/src/main.py +++ b/backend/src/main.py @@ -43,7 +43,7 @@ def create_app() -> FastAPI: if VERSION != "DEV_VERSION": app.mount("/assets", StaticFiles(directory="dist/assets"), name="assets") - # app.mount("/pwa", StaticFiles(directory="dist/pwa"), name="pwa") + app.mount("/images", StaticFiles(directory="dist/images"), name="images") # app.mount("/icons", StaticFiles(directory="dist/icons"), name="icons") templates = Jinja2Templates(directory="dist") @@ -73,16 +73,19 @@ def create_app() -> FastAPI: # return FileResponse("dist/sw.js") @app.get("/{path:path}") - def html(path: str): + def html(request: Request, path: str): files = os.listdir("dist") if path in files: return FileResponse(f"dist/{path}") else: - return FileResponse("dist/index.html") - - # # HTML Response - # @app.get("/{full_path:path}", response_class=HTMLResponse, tags=["html"]) - # def index(request: Request): + context = {"request": request} + return templates.TemplateResponse("index.html", context) + + # HTML Response + # @app.get("/{path:path}", response_class=HTMLResponse, tags=["html"]) + # def index(request: Request, path: str): + # print(request) + # print(path) # context = {"request": request} # return templates.TemplateResponse("index.html", context) diff --git a/backend/src/module/api/program.py b/backend/src/module/api/program.py index 8408f3bbf..4bed2f8f1 100644 --- a/backend/src/module/api/program.py +++ b/backend/src/module/api/program.py @@ -60,9 +60,15 @@ async def program_status(current_user=Depends(get_current_user)): if not current_user: raise UNAUTHORIZED if not program.is_running: - return {"status": "stop"} + return { + "status": False, + "version": VERSION, + } else: - return {"status": "running"} + return { + "status": True, + "version": VERSION, + } @router.get("/shutdown") @@ -81,10 +87,3 @@ async def check_downloader_status(current_user=Depends(get_current_user)): if not current_user: raise UNAUTHORIZED return program.check_downloader() - - -@router.get("/check/version", tags=["check"]) -async def check_version(current_user=Depends(get_current_user)): - if not current_user: - raise UNAUTHORIZED - return VERSION