Files
2026Technology-Competition/docs/superpowers/plans/2026-09-12-doubao-layout-fix.md
T

23 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 豆包式布局修复计划(崩溃 + 布局)
日期:2026-09-12
## Fix A — 修复 `Cannot set properties of null`(新旧资源缓存错配)
根因:`/` 返回启动时缓存、无缓存头的 HTML;静态资源无版本号 → 浏览器缓存旧 chat.js/chat.html 之一后新旧混用,`getElementById(...)` 为 null 时 `.textContent` 抛错。
修复:
1. `app.py`:启动时按 static 文件 `st_mtime_ns` 计算 `_ASSET_VER`,注入 `chat.html``__ASSET_VER__``index()` 返回 `HTMLResponse(..., headers={"Cache-Control":"no-store","Pragma":"no-cache"})`
2. `chat.html`4 个资源 URL 加 `?v=__ASSET_VER__`
3. `chat.js`:新增 `setText(el, v)`,关键 `.textContent` 赋值 null 安全(防白屏)。
4. 部署后强刷一次清掉旧 HTML 缓存。
## Fix B — 布局(去线 / 铺满 / 图标发送 / 省空间)
- `#composer`:去 `border-top`、背景透明、内边距收紧(与聊天区无缝)。
- `#composer-inner` / `#composer-toolbar` / `#upload-panel`:去 880px 限宽,输入框铺满右侧。
- `#send`:SVG 上箭头图标 + 40px 圆形按钮。
- `header`:高度 56→48、padding 收紧。
- 输入框改 `<textarea rows="1">` 自增高(≤160px);Enter 发送、Shift+Enter 换行。
- 消息区 `#chat` 保持 `max-width:880px` 居中(按用户选择)。
## 验证
`node --check``node --test``python -m pytest`(≥99%)→ 手动强刷核对。