Markdown渲染 + PRD需求文档(H Tab)

- mdRender(): 支持h1-h6/table/list/code/bold/link/blockquote/hr
- G 规范: dev-spec.md 以渲染后HTML展示
- H 需求: PRD.md 以渲染后HTML展示
- /api/prd: 新增路由读取PRD.md
This commit is contained in:
hmo
2026-07-14 02:49:08 +08:00
parent 71407681dd
commit 56c47a89cd
2 changed files with 40 additions and 3 deletions
+23
View File
@@ -941,6 +941,29 @@ def api_spec():
return jsonify({"ok": False, "error": str(e), "content": ""})
@app.route("/api/prd")
def api_prd():
"""返回产品需求文档 (PRD) 内容"""
candidates = [
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "docs", "PRD.md"),
os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "docs", "PRD.md"),
]
prd_path = None
for c in candidates:
p = os.path.normpath(c)
if os.path.exists(p):
prd_path = p
break
if not prd_path:
return jsonify({"ok": False, "error": "PRD.md not found", "content": ""})
try:
with open(prd_path, "r", encoding="utf-8") as f:
content = f.read()
return jsonify({"ok": True, "content": content, "path": prd_path})
except Exception as e:
return jsonify({"ok": False, "error": str(e), "content": ""})
@app.route("/api/platform")
@app.route("/api/health")
def api_health():