Archived
feat(routes): 迁移首页/静态资源 + /auth/me 认证状态
- web/routers/index.py:GET / 首页,用 Jinja2 以 Flask 同口径渲染 (keep_trailing_newline=False)——输出与 Flask render_template 逐字节一致 - web/app.py:挂载 /static 静态资源(site_auth.js 等,与 Flask 同目录) - web/routers/auth_status.py:/api/v1/auth/me 认证状态 · user/duration_text/announcement/smtp_configured/register_credits 逐字段对齐 - core/repo.py:补 get_announcement / get_smtp_config / smtp_configured 异步读 契约奇偶校验:28 项全 OK(新增 index 逐字节、auth:me); 验证:pytest 51/51;ruff All checks passed;pyright 0 errors; uvicorn 实跑 / 与 /static 与 /api/v1/* 均 200。
This commit is contained in:
1 parent
0104ae55e5
commit
18c77296c2
4 files changed
+144
No files matched your search
@@ -59,6 +59,23 @@ async def get_user_by_id(uid: int) -> dict[str, Any] | None:
|
||||
return dict(row) if row is not None else None
|
||||
|
||||
|
||||
# ---------- 公告 / SMTP 配置(读) ----------
|
||||
|
||||
async def get_announcement() -> dict[str, Any]:
|
||||
row = await db.fetch_one('SELECT * FROM announcements WHERE id = 1')
|
||||
return dict(row) if row else {'title': '', 'content': '', 'popup_mode': 'off'}
|
||||
|
||||
|
||||
async def get_smtp_config() -> dict[str, Any]:
|
||||
row = await db.fetch_one('SELECT * FROM smtp_config WHERE id = 1')
|
||||
return dict(row) if row else {}
|
||||
|
||||
|
||||
async def smtp_configured() -> bool:
|
||||
cfg = await get_smtp_config()
|
||||
return bool(cfg.get('host') and cfg.get('sender') and cfg.get('password'))
|
||||
|
||||
|
||||
# ---------- billing ledger(只读对账) ----------
|
||||
|
||||
async def ledger_open_count() -> int:
|
||||
|
||||
Reference in new issue
Block a user