fix(审核): 审核列表返回真实HTML内容+支持全部状态筛选

- list_all() 替代 list_pending(), 支持 ?status= 过滤
- 审核列表对 html 模式调用 _load_html_content() 从 OSS 加载真实源码
- 修复 page_type 不一致数据(embed_url有值但page_type=html)
- admin端预览直接用返回的htmlContent生成Blob URL, 不再fetch /oss/
This commit is contained in:
Pine
2026-09-05 02:30:29 +08:00
parent 754a28eded
commit e1459cda12
2 changed files with 14 additions and 3 deletions
+7 -3
View File
@@ -418,17 +418,21 @@ async def get_user_page(user_id: str, db: Database = Depends(get_db),
# ── 运营端:审核 ────────────────────────────────────────────────────────
@router.get("/admin/review/list", summary="运营端:待审核个人主页列表")
async def review_list(db: Database = Depends(get_db),
@router.get("/admin/review/list", summary="运营端:个人主页列表(含HTML内容)")
async def review_list(status: str | None = None,
db: Database = Depends(get_db),
user: dict = Depends(get_current_user)):
if user.get("role") not in ("admin", "operator"):
raise HTTPException(status_code=403, detail="无权限")
pages = await db.user_pages.list_pending()
pages = await db.user_pages.list_all(status)
result = []
for p in pages:
u = (await db.users.get_by_id(p["userId"])) or {}
# 加载真实 HTML 内容(从 OSS 读取,兼容旧数据 html_content 列)
html_content = await _load_html_content(p) if p.get("pageType") == "html" else ""
result.append({
**p,
"htmlContent": html_content,
"nickname": u.get("nickname") or u.get("username"),
"avatar": resolve_url(u.get("avatar") or ""),
})
+7
View File
@@ -701,3 +701,10 @@ class UserPageRepository:
"operatorName": r.operator_name, "note": r.note, "createdAt": r.created_at}
for r in rows
]
async def list_all(self, status: str | None = None) -> list[dict]:
stmt = select(UserPage).order_by(UserPage.updated_at.desc())
if status:
stmt = stmt.where(UserPage.review_status == status)
rows = (await self.session.execute(stmt)).scalars().all()
return [self._to_dict(r) for r in rows]