"""帮助中心静态页面。""" from pathlib import Path from fastapi import HTTPException from fastapi.responses import FileResponse from settings import BACKEND_DIR, PROJECT_ROOT HELP_STATIC_DIR = BACKEND_DIR / "static" / "help" CREDENTIAL_TOOL_CANDIDATES = ( PROJECT_ROOT / "凭证采集工具.html", HELP_STATIC_DIR / "credential-tool.html", ) LINK_CARD_DEBUG_HTML = HELP_STATIC_DIR / "link-card-debug.html" def _resolve_credential_tool_html() -> Path: for path in CREDENTIAL_TOOL_CANDIDATES: if path.is_file(): return path raise HTTPException(status_code=404, detail="凭证采集工具页面不存在") def serve_credential_tool() -> FileResponse: html_path = _resolve_credential_tool_html() return FileResponse( html_path, media_type="text/html; charset=utf-8", content_disposition_type="inline", ) def serve_link_card_debug_guide() -> FileResponse: if not LINK_CARD_DEBUG_HTML.is_file(): raise HTTPException(status_code=404, detail="链接卡片联调指南不存在") return FileResponse( LINK_CARD_DEBUG_HTML, media_type="text/html; charset=utf-8", content_disposition_type="inline", )