refactor: split monolithic main.py into services/ + ui/ modules (improve-maintainability)
- main.py: 4360 → 146 lines (96.6% reduction), entry layer only - services/: rate_limiter, autostart, persona, connection, profile, hotspot, content, engagement, scheduler, queue_ops (10 business modules) - ui/app.py: all Gradio UI code extracted into build_app(cfg, analytics) - Fix: with gr.Blocks() indented inside build_app function - Fix: cfg.all property (not get_all method) - Fix: STATUS_LABELS, get_persona_keywords, fetch_proactive_notes imports - Fix: queue_ops module-level set_publish_callback moved into configure() - Fix: pub_queue.format_*() wrapped as queue_format_table/calendar helpers - All 14 files syntax-verified, build_app() runtime-verified - 58/58 tasks complete"
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: 内容生成函数迁移至独立模块
|
||||
系统 SHALL 将内容生成、图片生成、发布及导出相关函数从 `main.py` 提取至 `services/content.py`,包括:`generate_copy`、`generate_images`、`one_click_export`、`publish_to_xhs`。
|
||||
|
||||
#### Scenario: 模块导入成功
|
||||
- **WHEN** `main.py` 执行 `from services.content import generate_copy, generate_images, publish_to_xhs, one_click_export`
|
||||
- **THEN** 所有函数可正常调用,行为与迁移前完全一致
|
||||
|
||||
#### Scenario: 内容生成保留现有验证逻辑
|
||||
- **WHEN** 调用 `publish_to_xhs` 时标题超过 20 字或图片数量不合法
|
||||
- **THEN** 函数 SHALL 返回与迁移前相同的错误提示,不改变验证行为
|
||||
|
||||
#### Scenario: 临时文件清理逻辑保留
|
||||
- **WHEN** `publish_to_xhs` 执行完毕(成功或失败)
|
||||
- **THEN** `finally` 块中的 AI 临时文件清理逻辑 SHALL 正常执行
|
||||
Reference in New Issue
Block a user