系统日志
- {{ logContent }}
- diff --git a/platform/backend/app/api/articles.py b/platform/backend/app/api/articles.py
index d630ab1..3a04e22 100644
--- a/platform/backend/app/api/articles.py
+++ b/platform/backend/app/api/articles.py
@@ -1,4 +1,4 @@
-from fastapi import APIRouter, HTTPException, Query, Depends
+from fastapi import APIRouter, HTTPException, Query, Depends, Body
from sqlalchemy.orm import Session
from sqlalchemy import or_
from pathlib import Path
@@ -140,6 +140,31 @@ def preview_article(topic_id: str, platform: str = "zhihu", current_user: User =
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}
+@router.put("/{topic_id}/content")
+def update_article_content(
+ topic_id: str,
+ platform: str = Body(...),
+ html_content: str = Body(...),
+ current_user: User = Depends(get_current_user),
+ db: Session = Depends(get_db)
+):
+ """保存用户编辑后的文章 HTML 内容"""
+ topic = db.query(Topic).filter(Topic.id == topic_id).first()
+ if topic and current_user.role != "admin" and topic.org_id != current_user.org_id:
+ raise HTTPException(status_code=404, detail="Topic not found")
+ article_id = f"{platform}_{topic_id}"
+ article = db.query(Article).filter(Article.id == article_id).first()
+ if not article:
+ article = Article(
+ id=article_id, topic_id=topic_id, platform=platform,
+ file_path=f"db:{article_id}", status="draft"
+ )
+ db.add(article)
+ article.html_content = html_content
+ article.updated_at = datetime.now()
+ db.commit()
+ return {"ok": True, "id": article_id}
+
@router.get("/optimization-report")
def get_optimization_report(publish_date: str = None, current_user: User = Depends(get_current_user)):
"""获取合规优化报告"""
diff --git a/platform/backend/app/api/system.py b/platform/backend/app/api/system.py
index 4c4df96..2b08961 100644
--- a/platform/backend/app/api/system.py
+++ b/platform/backend/app/api/system.py
@@ -187,7 +187,7 @@ def get_modules_status():
today_str = date.today().isoformat()
log_based: dict = {
"scheduled_collect": {"name": "📡 内容采集", "log": LOGS_DIR / f"collector_{today_str}.log"},
- "scheduled_sync": {"name": "🔄 指标同步", "log": LOGS_DIR / f"sync_{today_str}.log"},
+ "scheduled_sync": {"name": "🔄 数据同步", "log": LOGS_DIR / f"sync_{today_str}.log"},
"scheduled_generate": {"name": "🤖 内容创作", "log": LOGS_DIR / f"creator_{today_str}.log"},
"scheduled_optimize": {"name": "🔍 内容优化", "log": LOGS_DIR / f"optimizer_{today_str}.log"},
"scheduled_optimize_sources": {"name": "📡 信息源优化", "log": LOGS_DIR / f"optimizer_sources_{today_str}.log"},
@@ -207,7 +207,7 @@ def get_modules_status():
task_count = content.count("完成") + content.count("success") + content.count("SUCCESS")
total = task_count + content.count("失败") + content.count("failed") + content.count("ERROR")
success_rate = round(task_count / total * 100) if total > 0 else None
- status = "running" if log_file.exists() else ("idle" if mod_id in jobs else "stopped")
+ status = "running" if mod_id in jobs else "stopped"
modules.append({
"id": mod_id,
"title": cfg["name"],
diff --git a/platform/backend/app/api/tasks.py b/platform/backend/app/api/tasks.py
index 1cc26a5..937b40d 100644
--- a/platform/backend/app/api/tasks.py
+++ b/platform/backend/app/api/tasks.py
@@ -17,10 +17,11 @@ def list_tasks(
topic_id: Optional[str] = None,
stage: Optional[str] = None,
limit: int = Query(50, le=200),
+ offset: int = Query(0, ge=0),
db: Session = Depends(get_db),
current_user=Depends(get_current_user)
):
- query = db.query(ContentTask).join(Topic, ContentTask.topic_id == Topic.id, isouter=True)
+ query = db.query(ContentTask, Topic.title.label("topic_title")).join(Topic, ContentTask.topic_id == Topic.id, isouter=True)
of = org_filter(current_user, Topic)
if of is not True:
query = query.filter((ContentTask.topic_id.is_(None)) | (Topic.org_id == current_user.org_id))
@@ -30,7 +31,13 @@ def list_tasks(
query = query.filter(ContentTask.topic_id == topic_id)
if stage:
query = query.filter(ContentTask.stage == stage)
- return query.order_by(ContentTask.created_at.desc()).limit(limit).all()
+ rows = query.order_by(ContentTask.created_at.desc()).offset(offset).limit(limit).all()
+ result = []
+ for r in rows:
+ task = r.ContentTask
+ task.topic_title = r.topic_title
+ result.append(task)
+ return result
@router.get("/active")
diff --git a/platform/backend/app/schemas.py b/platform/backend/app/schemas.py
index 1a5a0cb..97c0cd9 100644
--- a/platform/backend/app/schemas.py
+++ b/platform/backend/app/schemas.py
@@ -319,6 +319,8 @@ class ContentTaskCreate(BaseModel):
class ContentTaskResponse(ContentTaskBase):
id: int
task_id: str
+ topic_id: Optional[str] = None
+ topic_title: Optional[str] = None
result_data: Dict[str, Any] = {}
error_msg: Optional[str] = None
started_at: Optional[datetime] = None
diff --git a/platform/frontend/admin.html b/platform/frontend/admin.html
index 80ed5ae..5854add 100644
--- a/platform/frontend/admin.html
+++ b/platform/frontend/admin.html
@@ -26,9 +26,11 @@
{{ logContent }}
+ {{ logContent }}
- 正在跳转到 系统管理 → 运行日志...