Skip to content

Reduce binary size with font subsetting and compressed web assets - #6

Merged
vvbbnn00 merged 4 commits into
mainfrom
dev
Oct 11, 2026
Merged

vvbbnn00 merged 4 commits into
mainfrom
dev

Conversation

@vvbbnn00

Copy link
Copy Markdown
Member

说明

减少 WebUI 字体、内嵌资源和发布包的体积。

以 Linux amd64 发布构建为例:

项目 优化前 优化后
字体文件 4.65 MB 0.25 MB
二进制 16.18 MB 11.42 MB
发布压缩包 9.22 MB 4.74 MB

主要改动

  • 构建时自动收集前端固定文案和 Go 后端消息,裁剪 Noto Sans SC 字形,保留可变字重、hinting 和排版信息。Geist 与 Geist Mono 保留完整字库。
  • 开发模式保留完整中文字体,开发与发布构建使用独立生成目录,避免互相覆盖。动态内容中未预置的汉字使用系统字体回退,字形可能略有差异。
  • HTML、JS、CSS 等文本资源按 gzip 压缩后嵌入,读取时还原原始内容。每个压缩资源仅解压一次,每次请求使用独立读取位置,保留 MIME、HEAD、Range 和缓存行为。
  • 保留原始 Vite 输出供 preview 使用,保护 .gitkeep 和已有 .gz 文件,提高 tar.gz 与 ZIP 的压缩等级。
  • 修复静态资源测试对 JavaScript MIME 类型的硬编码,使断言兼容 Windows 的系统映射。

验证

  • 前端 20 项测试、Go 全量测试、相关 race 检查及 go vet 通过。
  • 六个平台的发布构建、归档完整性和 SHA256 校验通过。
  • 保留字形在六种字重下的轮廓和字宽与原字体一致;浏览器检查覆盖主题切换、详情弹窗、短信提交、动态文字回退和手机布局。
  • 已复现并修复 Windows MIME 断言失败,两种 MIME 映射的本地模拟测试通过;Windows CI 待重跑确认。

Collect panel text and backend messages while preserving variable font
weights, layout features and licensing metadata. Keep complete fonts
for development in a separate directory and retain the existing system
fallback for dynamic characters.

Cover Unicode source collection and development/production coexistence.
Store text assets as gzip and restore their original bytes for HTTP
serving. Decode immutable assets once and give each request its own
reader, preserving MIME types, HEAD, Range and cache behavior.

Keep raw Vite output for preview, preserve the checkout marker and
existing gzip sidecars, and test packing round trips and concurrent reads.
Use gzip level 9 for tar archives and the highest Deflate level for ZIP
packages without changing archive formats or package contents.
Copilot AI balanced review requested due to automatic review settings October 11, 2026 10:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vvbbnn00
vvbbnn00 merged commit 1ee5af7 into main Oct 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants