feat: 增加升级说明页,退出弹窗默认选退出系统
This commit is contained in:
+12
-1
@@ -17,7 +17,7 @@ logging.getLogger("httpcore").setLevel(logging.WARNING)
|
||||
|
||||
from fastapi import Depends, FastAPI, HTTPException, Request, Response, WebSocket, WebSocketDisconnect
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.responses import FileResponse, JSONResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from pydantic import BaseModel, Field
|
||||
from sqlalchemy.orm import Session
|
||||
@@ -674,5 +674,16 @@ class _WebFiles(StaticFiles):
|
||||
|
||||
|
||||
_dist = Path(__file__).resolve().parents[2] / "web" / "dist"
|
||||
|
||||
|
||||
@app.get("/msg01", include_in_schema=False)
|
||||
@app.get("/msg01/", include_in_schema=False)
|
||||
def notice_page() -> FileResponse:
|
||||
index = _dist / "index.html"
|
||||
if not index.is_file():
|
||||
raise HTTPException(status_code=404, detail="页面不存在")
|
||||
return FileResponse(index, headers={"Cache-Control": "no-cache"})
|
||||
|
||||
|
||||
if _dist.is_dir():
|
||||
app.mount("/", _WebFiles(directory=_dist, html=True), name="web")
|
||||
|
||||
@@ -1220,3 +1220,12 @@ def test_exam_list_rejects_unrecognized_page() -> None:
|
||||
client.client = HTTP()
|
||||
with pytest.raises(RuntimeError, match="考试列表没有获取到"):
|
||||
client.my_exams()
|
||||
|
||||
|
||||
def test_notice_page_is_reachable_only_by_its_address() -> None:
|
||||
import euniv.api as api_module
|
||||
|
||||
response = TestClient(api_module.app).get("/msg01")
|
||||
assert response.status_code == 200
|
||||
assert 'id="app"' in response.text
|
||||
assert response.headers["cache-control"] == "no-cache"
|
||||
|
||||
Reference in New Issue
Block a user