Phase3: 三平台封面图生成
- cover_generator.py: Pillow生成知乎/微信/小红书封面图(渐变背景+标题) - 知乎 1200×630 蓝调, 微信 900×500 绿调, 小红书 1080×1440 红调 - creator.py 流水线增加 cover_generator 作为最终回退 - db_helper.py 新增 save_cover_to_article - main.py 挂载 /automation/images 静态目录 - articles.py preview 接口返回 images 字段 - topics.html 预览dialog展示封面图
This commit is contained in:
@@ -138,7 +138,7 @@ def preview_article(topic_id: str, platform: str = "zhihu", current_user: User =
|
||||
article = db.query(Article).filter(Article.id == article_id).first()
|
||||
if not article or not article.html_content:
|
||||
raise HTTPException(status_code=404, detail=f"Article not found for {topic_id} on {platform}")
|
||||
return {"topic_id": topic_id, "platform": platform, "html": article.html_content}
|
||||
return {"topic_id": topic_id, "platform": platform, "html": article.html_content, "images": article.images or {}}
|
||||
|
||||
@router.put("/{topic_id}/content")
|
||||
def update_article_content(
|
||||
|
||||
@@ -95,6 +95,13 @@ app.include_router(platform_config.router)
|
||||
app.include_router(collector_mgmt.router)
|
||||
app.include_router(assistant.router)
|
||||
|
||||
# 挂载自动生成的图片(必须先于前端根挂载)
|
||||
PROJECT_ROOT_DIR = Path(__file__).parent.parent.parent.parent
|
||||
AUTOMATION_IMAGES_DIR = PROJECT_ROOT_DIR / "automation" / "images"
|
||||
if AUTOMATION_IMAGES_DIR.exists():
|
||||
app.mount("/automation/images", StaticFiles(directory=str(AUTOMATION_IMAGES_DIR)), name="images")
|
||||
logger.info(f"Images mounted at /automation/images from {AUTOMATION_IMAGES_DIR}")
|
||||
|
||||
# 挂载前端
|
||||
FRONTEND_DIR = Path(__file__).parent.parent.parent / "frontend"
|
||||
if FRONTEND_DIR.exists() and (FRONTEND_DIR / "index.html").exists():
|
||||
|
||||
Reference in New Issue
Block a user