feat: 每月定时开始学习并改为本地计算心跳摘要

This commit is contained in:
2026-11-15 01:30:24 +08:00
parent e9a1e9b315
commit caa79d79b7
14 changed files with 510 additions and 35 deletions
+32
View File
@@ -46,6 +46,13 @@ class ProxyBody(_BaseModel):
password: str | None = None
class StudyStartBody(_BaseModel):
day: int
hour: int
minute: int
second: int
@asynccontextmanager
async def lifespan(_app: FastAPI):
init_db()
@@ -225,6 +232,31 @@ def put_monthly_target(body: MonthlyTargetBody, request: Request, db: Session =
return {"monthly_target": account.monthly_target}
@app.get("/api/settings/study-start")
def get_study_start(request: Request, db: Session = Depends(get_db)) -> dict:
from euniv.study_window import view_of
account = db.get(Account, _signed_in(request, db))
if account is None:
raise HTTPException(status_code=401, detail="未登录")
return view_of(account)
@app.put("/api/settings/study-start")
def put_study_start(body: StudyStartBody, request: Request, db: Session = Depends(get_db)) -> dict:
from euniv.study_window import StudyWindowError, apply, view_of
account = db.get(Account, _signed_in(request, db))
if account is None:
raise HTTPException(status_code=401, detail="未登录")
try:
apply(account, body.day, body.hour, body.minute, body.second)
except StudyWindowError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
db.commit()
return view_of(account)
@app.get("/api/settings/proxy")
def get_proxy(request: Request, db: Session = Depends(get_db)) -> dict:
from euniv.proxy import view_of