Skip to content

feat(export_messages): HTML 内联 base64 图片改成可选 flag (--inline-images),默认相对路径 #109

@ylytdeng

Description

@ylytdeng

问题

PR #107 引入的 export_messages.py 在导出 HTML 时,把每张图片的解密结果 base64 编码内联到 HTML(line 489-492)。

后果:

  • 大群一天几百张图 × 单张 5-10MB → 单个 messages.html 几 GB
  • 浏览器打开秒死(Chrome / Edge 都会 OOM)
  • 邮件 / 即时通讯转发 HTML 不可能(附件超限)

现状代码

# export_messages.py (大约 line 489)
img_b64 = base64.b64encode(img_bytes).decode('ascii')
html += f'<img src="data:image/{fmt};base64,{img_b64}">'

建议方案

加 CLI flag:

python export_messages.py --inline-images   # 老行为(小群可用)
python export_messages.py                   # 默认:写 image/<md5>.<ext> + <img src="image/xxx.jpg">

实现:

  1. 默认走相对路径模式:<output_base_dir>/<display_name>/image/<md5>.<ext> 存图片,HTML 用 <img src="image/xxx.jpg">
  2. --inline-images 时走老路径(base64)
  3. README + EXE_USAGE 文档同步更新

Acceptance

  • 默认不再内联,HTML 体积 < 总图片体积 + 100KB
  • --inline-images flag 仍能内联(向后兼容)
  • HTML 用相对路径,能被打包成 zip 给别人看
  • EXE_USAGE.md 描述新的输出布局

相关

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions