docs(网关): 补全 base64→url 映射表(接口1/2/3/5) + 嵌套数组/超时提醒

接口 1/2/3/5 已真实实现,补齐网关需要的字段映射,供网关开发参考:
- 网关任务书 §6:完整映射表(annotated_image / results[].image / results[].grown_image /
  best_hairline_image / hair_growth_image / hairline_images[].image);推荐"凡 *_base64 递归改写"
  通用实现;可空字段(生发图)保留 null;gender 等入参网关透传无需改造
- 网关任务书 §9:接口4 仍 mock;生发接口(2/3) ComfyUI 同步出图慢,request_timeout 调大≥120s
- 架构 §9:标注两个易漏点(数组内字段需递归、生发图可空)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
xsl
2026-06-15 00:29:33 +08:00
co-authored by Claude Opus 4.8
parent 38161d1b50
commit 147fef6ca6
2 changed files with 27 additions and 3 deletions
@@ -184,9 +184,15 @@
- 删除该 base64 字段,新增对应的 `*_url` 字段,值为 `https://hair.xiangsilian.com/static/annotations/{uuid}.png`
3. 客户端最终看到的字段名/URL **与接口文档完全一致**(如 `annotated_image_url`)。
> 网关持有一份「接口 → 图片字段映射表(接口1: `annotated_image` ↔ 接口5: `hairline_image` 等),按表把内部 `*_base64` 转成对外 `*_url`。映射表以接口文档为准。
> **完整字段映射表见 [`网关-开发任务书.md`](网关-开发任务书.md) §6**(接口1/2/3/5 全部 `*_base64``*_url`,以 `接口文档.md` 为准
> ⚠️ 两个易漏点:
> 1. **数组里的图片字段**:接口2 `results[].image_base64`/`results[].grown_image_base64`、接口5
> `hairline_images[].image_base64` 在数组元素内——改写逻辑要**递归进数组**(建议「凡 key 以 `_base64`
> 结尾就改写」的通用递归,自动覆盖嵌套与未来新增字段)。
> 2. **可空字段**:接口2/3 的生发图(ComfyUI 未起/失败时)`*_base64` 为 **null** → 保留 null,不落盘。
>
> 代价:内部 HTTP 多传一份 base64(图片放大约 1.33×)。worker↔网关若跨网络,单图 ~100KB–1MB 量级,可接受。
> ⚠️ 生发接口(2/3)经 ComfyUI 同步出图较慢(接口2 ~18s、接口3 ~6s),网关转发**超时要调大(≥120s)**。
>
> 静态文件清理:网关 `static/annotations/` 会持续增长,需加定期清理(按时间或容量,定时任务),与拆分前同样的问题,由网关侧负责。