Commit Graph

2 Commits

Author SHA1 Message Date
caoqianming 25d8a6572f refactor(web): app.py 拆分——73 路由迁 11 个 router 模块,3972 行减至 732
照 admin.py 的 register_*_routes 注册范式把 create_app 巨型闭包拆开,
依赖(require_user/auth_cfg)显式传参,对外 /v1 契约零变化:

- web/routers/:misc/models/authroutes/wechat(含企微)/kb/schedules/
  skills_memory/files/asr/tasks/messages 共 11 个模块
- web/common.py:跨 router 常量与 helper(task_dict/usage_aggregates/
  sse_event/assert_owns_task 等)
- web/schemas.py:13 个 Pydantic 请求模型独立成文件
- web/model_gate.py:模型档位门控 + image/video variant 解析
- web/runs.py:run_agent_bg + run_channel_conversation(BG worker 与
  渠道入站对话核心,从 app.py 模块级函数析出)
- web/userfiles.py:路径安全原语(safe_join 越界校验/transfer 预检)收口
- app.py 只剩 App 工厂 + lifespan 后台协程群

验证:286 测试全过;路由面 81 条逐条一致;TestClient 冒烟
(healthz 200/坏 platform_key 403/未鉴权 401/lifespan 正常启动)。
test_changelog/test_pptx_render 的 import 指向同步更新。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 10:18:57 +08:00
caoqianming b70b993257 feat(preview): pptx 在线预览 —— LibreOffice→PDF + 复用 PDF iframe(DESIGN §8.3 Stage 1)
文件区点 .pptx 不再只能下载。后端转 PDF,前端复用现成 PDF iframe。

- web/pptx_render.py: pptx_to_pdf() 调 soffice,独立临时 profile 绕单 profile
  锁、60s 超时 kill;缓存 .preview/<stem>.<hash>.pdf(hash=mtime+size,源改即
  失效,prune 旧 hash);soffice 缺失抛 SofficeNotFoundError
- web/app.py: GET /v1/files/preview_pdf —— _safe_join 防穿越 + 仅 .ppt(x) +
  per-path asyncio.Lock 防并发重转 + run_in_executor 不堵事件循环;缺失 501/失败 500
- preview.js: ppt 组 + main/mini 共用 _showPptAsPdf(spinner loading + 失败回退下载)
- dev.html: .preview-spinner(复用 @keyframes spin)
- 转换跑 web host 进程不进沙盒;部署 host 装 libreoffice-impress + fonts-noto-cjk
  (sandbox Dockerfile 不动)
- tests/test_pptx_render.py: 10 例(缓存命中跳 soffice/源变失效+prune/缺失降级/越界拒绝)
- 文档:RUN.md(host 装 + 故障兜底 2 行)、PROGRESS.md

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 13:04:02 +08:00