修复复盘保存 405:复盘改走成绩更新接口,并修正 API 404 回退。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-28 16:48:20 +08:00
parent bec9df5d6f
commit f7a761da33
4 changed files with 16 additions and 7 deletions
+9 -1
View File
@@ -71,9 +71,17 @@ if dist_dir is not None:
if assets_dir.is_dir(): if assets_dir.is_dir():
app.mount("/assets", StaticFiles(directory=assets_dir), name="assets") app.mount("/assets", StaticFiles(directory=assets_dir), name="assets")
@app.api_route(
"/api/{rest:path}",
methods=["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"],
include_in_schema=False,
)
async def api_not_found(rest: str):
raise HTTPException(status_code=404, detail="Not Found")
@app.get("/{full_path:path}", include_in_schema=False) @app.get("/{full_path:path}", include_in_schema=False)
async def serve_spa(full_path: str): async def serve_spa(full_path: str):
if full_path.startswith("api") or full_path.startswith("api/"): if full_path.startswith("api/") or full_path == "api":
raise HTTPException(status_code=404, detail="Not Found") raise HTTPException(status_code=404, detail="Not Found")
if full_path in ("", "index.html"): if full_path in ("", "index.html"):
return FileResponse(dist_dir / "index.html") return FileResponse(dist_dir / "index.html")
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -9,7 +9,7 @@
<meta name="author" content="马建军" /> <meta name="author" content="马建军" />
<meta name="copyright" content="Copyright (c) 马建军. All rights reserved." /> <meta name="copyright" content="Copyright (c) 马建军. All rights reserved." />
<title>中学成绩档案</title> <title>中学成绩档案</title>
<script type="module" crossorigin src="/assets/index-C801hcLu.js"></script> <script type="module" crossorigin src="/assets/index-BlbLMdT7.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BSTLtBBx.css"> <link rel="stylesheet" crossorigin href="/assets/index-BSTLtBBx.css">
</head> </head>
<body> <body>
+5 -4
View File
@@ -64,13 +64,14 @@ export default function ExamReviewPanel({ exams, onRefresh }: Props) {
} }
setSaving(true) setSaving(true)
try { try {
await examApi.updateReview( await examApi.update(selectedExam.id, {
selectedExam.id, scores: selectedExam.scores.map((score) => ({
selectedExam.scores.map((score) => ({
subject_id: score.subject_id, subject_id: score.subject_id,
total_score: Number(score.total_score),
obtained_score: Number(score.obtained_score),
review_statuses: statusMap[score.subject_id] || [], review_statuses: statusMap[score.subject_id] || [],
})), })),
) })
message.success('复盘已保存') message.success('复盘已保存')
onRefresh() onRefresh()
} catch (err) { } catch (err) {