feat: 平台配置表扩展配图/字数字段,微信公众号正文插入配图,合规检查从DB读规则

- PlatformConfig模型新增requires_image、image_count_min/max、image_width/height、min_words/max_words
- schemas.py同步PlatformConfigBase/Create/Update/Response新字段
- initial_data.py为三大平台填充初始值(微信需配图、字数800-1500等)
- database.py添加新列ALTER TABLE迁移
- platforms.html重写编辑弹窗(正确字段名+配图/字数设置)
- writer.py微信公众号文章正文h1后插入<img>占位
- compliance_checker.py接受platform_config参数,从DB读取规则替代硬编码
- compliance_optimizer.py启动时加载DB平台配置传入checker
This commit is contained in:
Yuzhiran Dev
2026-05-17 23:08:43 +08:00
parent 5674114599
commit 41b0f694ee
9 changed files with 174 additions and 51 deletions
+11
View File
@@ -351,6 +351,17 @@ class Writer:
html = template.replace("{{TITLE}}", title).replace("{{DATE}}", TODAY).replace("{{GEN_TIME}}", GEN_TIME)
html_content = _md_parser(adapted)
# WeChat: insert image placeholder at start of body
if platform == "wechat":
img_tag = '<p><img src="placeholder.jpg" alt="配图" style="width:100%;max-width:1080px;border-radius:8px;"></p>\n'
# Insert after <h1> if present, else prepend
h1_end = html_content.find('</h1>')
if h1_end != -1:
html_content = html_content[:h1_end + 5] + '\n' + img_tag + html_content[h1_end + 5:]
else:
html_content = img_tag + html_content
html = html.replace("<!-- CONTENT -->", html_content)
tags_html = self._get_platform_tags(platform)