feat: 数据源统一与前端预览修复
=== 后端核心 === - db_helper: 统一数据库访问抽象层 - system.py API: * 参数绑定修复: 使用 Body(embed=True) 接收 JSON * 添加请求日志记录 - sync.py: 仅导出 DB→JSON(备份) === 合规与流水线 === - compliance_checker: 标签检测优化(仅检查容器,避免正文误判) - 所有脚本(creator/collector/writer/outline/research等)统一使用数据库 === 前端改版 === - topics.html: * 创作/优化 API 路径修正 * 预览弹窗重设计:多平台并行加载、富文本显示、单复制按钮 * 状态中文映射(getStatusLabel) * 认证检查 - 所有 HTML 静态资源路径修复(移除 /static 前缀) === 数据一致性 === - 数据库状态统一为英文(pending/review/ready/published) - 前端显示中文化映射 已测试 A03 流水线完整通过。
This commit is contained in:
+45
-7
@@ -1,8 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
data = json.load(open('automation/data/sustainability_topics.json', 'r', encoding='utf-8'))
|
||||
for t in data:
|
||||
if t and t.get('id') == 'D01':
|
||||
t['priority_score'] = 12
|
||||
print(f"D01 priority_score set to {t['priority_score']}")
|
||||
json.dump(data, open('automation/data/sustainability_topics.json', 'w', encoding='utf-8'), ensure_ascii=False, indent=2)
|
||||
import sys
|
||||
from pathlib import Path
|
||||
PROJECT_ROOT = Path(__file__).parent.parent
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
try:
|
||||
from db_helper import update_topic_status
|
||||
from app.database import SessionLocal
|
||||
from app.models import Topic as DBTopic
|
||||
HAVE_DB = True
|
||||
except ImportError:
|
||||
HAVE_DB = False
|
||||
DATA_DIR = PROJECT_ROOT / "automation" / "data"
|
||||
TOPICS_FILE = DATA_DIR / "sustainability_topics.json"
|
||||
def adjust(adjustments):
|
||||
db_ok = False
|
||||
if HAVE_DB:
|
||||
db = SessionLocal()
|
||||
try:
|
||||
for tid, new_score in adjustments.items():
|
||||
topic = db.query(DBTopic).filter(DBTopic.id == tid).first()
|
||||
if topic:
|
||||
topic.priority_score = new_score
|
||||
topic.updated_at = datetime.datetime.now()
|
||||
db.commit()
|
||||
db_ok = True
|
||||
finally:
|
||||
db.close()
|
||||
try:
|
||||
with open(TOPICS_FILE, 'r', encoding='utf-8') as f:
|
||||
topics = json.load(f)
|
||||
for t in topics:
|
||||
if t['id'] in adjustments:
|
||||
t['priority_score'] = adjustments[t['id']]
|
||||
with open(TOPICS_FILE, 'w', encoding='utf-8') as f:
|
||||
json.dump(topics, f, ensure_ascii=False, indent=2)
|
||||
except:
|
||||
pass
|
||||
return db_ok
|
||||
def main():
|
||||
adjustments = {'D01': 12}
|
||||
adjust(adjustments)
|
||||
print("D01 priority_score set to 12")
|
||||
if __name__ == "__main__":
|
||||
import json, datetime
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user