fix(web): vendor Inter so image builds skip Google Fonts
BUG-430 loaded Inter via next/font/google, which failed Gitea publish run 2408 when the Docker build could not reach fonts.googleapis.com. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+21
-4
@@ -6578,15 +6578,15 @@
|
||||
|
||||
- 状态:resolved
|
||||
- 首次发现:2026-08-29
|
||||
- 最近更新:2026-08-29
|
||||
- 最近更新:2026-09-05
|
||||
- 影响面:全站 `--font-body`、后台 antd `fontFamily`
|
||||
- 用户现象:设计稿写了 Inter,实际请求里没有 woff2;非苹果系统落到 Segoe UI / 微软雅黑。
|
||||
- 触发条件:打开任意带根布局的页面。
|
||||
- 根因:仓库 0 个字体文件、0 处 `@font-face`、0 处 `next/font`,CSS 与 admin token 却把 Inter 写在 StyreneB 之后。
|
||||
- 修复:根布局用 `next/font/google` 加载 Inter(`display: "swap"`、`--font-inter`)。`--font-body` 与 admin `fontFamily` 改为 `var(--font-inter, Inter)`。Tiempos / 宋体栈未改。构建产物与 `/` HTML 可见 woff2 preload。
|
||||
- 修复:根布局用 `next/font/local` 加载仓内 `InterVariable-latin.woff2`(`display: "swap"`、`--font-inter`)。早期曾用 `next/font/google`,构建期会访问 Google Fonts,见 BUG-543。`--font-body` 与 admin `fontFamily` 改为 `var(--font-inter, Inter)`。Tiempos / 宋体栈未改。构建产物与 `/` HTML 可见 woff2 preload。
|
||||
- 验证:`frontend/tests/site-style-isolation-contract.test.ts`;`next build` 的 `/` HTML 含 Inter woff2 preload。
|
||||
- 防复发:字体栈里出现的西文家族必须有 `next/font` 或 `@font-face`;缺授权的展示字体(Tiempos)不得用同一套办法偷偷补上。
|
||||
- 相关记录:无
|
||||
- 防复发:字体栈里出现的西文家族必须有 `next/font/local`(仓内字体文件)或 `@font-face`;不得用 `next/font/google`。缺授权的展示字体(Tiempos)不得用同一套办法偷偷补上。
|
||||
- 相关记录:BUG-543
|
||||
- 复发自:无
|
||||
- 修复版本:待发布
|
||||
|
||||
@@ -8372,3 +8372,20 @@
|
||||
- 相关记录:BUG-390、BUG-540
|
||||
- 复发自:BUG-390(质量探针只对学业发出,但学业内 kind 未收紧)
|
||||
- 修复版本:待发布
|
||||
|
||||
## BUG-543 | staging 镜像构建因 Google Fonts 拉不到 Inter 失败
|
||||
|
||||
- 状态:resolved
|
||||
- 首次发现:2026-09-05
|
||||
- 最近更新:2026-09-05
|
||||
- 影响面:Gitea `backend-quality-gate.yml` `publish`、`deploy/railway-web.Dockerfile` 的 `RUN npm run build`、`frontend/src/app/layout.tsx`
|
||||
- 用户现象:无终端用户可见现象。门禁 validate 通过后 publish 失败,staging 不发布新镜像。
|
||||
- 触发条件:推送触及门禁路径后,publish 在 Docker 内执行 `npm run build`。构建环境访问不到 `fonts.googleapis.com`。
|
||||
- 根因:BUG-430 用 `next/font/google` 在构建期下载 Inter。validate 跑在 hostexecutor,能出网;publish 的镜像构建不能。Gitea run 2408(SHA `40c623ed`)报 `Failed to fetch Inter from Google Fonts`,`railway-web.Dockerfile:26` 退出 1。
|
||||
- 修复:把 latin 可变 Inter(OFL)放进 `frontend/src/app/fonts/InterVariable-latin.woff2`,根布局改 `next/font/local`。不改 workflow、不设构建期代理。字体栈与 `--font-inter` 不变。
|
||||
- 验证:`site-style-isolation-contract` 锁定 `next/font/local`、仓内 woff2 魔数、以及 `frontend/src` 不再出现 `next/font/google` / `fonts.googleapis.com`。本机 `npx tsx --test tests/site-style-isolation-contract.test.ts`;`tsc --noEmit`。
|
||||
- 防复发:不得把西文正文字体改回 `next/font/google`。新字体必须是仓内文件 + `next/font/local` 或 `@font-face`。
|
||||
- 相关记录:BUG-430
|
||||
- 复发自:BUG-430(加载方式在无 Google Fonts 网络的镜像构建里不成立)
|
||||
- 修复版本:待发布
|
||||
|
||||
|
||||
@@ -42,3 +42,13 @@
|
||||
| `run_quality_gate.py --profile quick` 内 `npm test` | 2682 tests / 2673 pass / **9 fail**,全部是 Docker 迁移 `database migration failed`(`database-foundation` / `database-local-business` / redeem / identity / secret-refs / v9×3 / Skill migration)。与本单无关,属既有环境缺口。 |
|
||||
|
||||
未跑全量 `npm test`(时间);未做浏览器真人走查(无登录态)。清单:`docs/testing/rectification-quality-probe-dedupe-20260904.md`。
|
||||
|
||||
## 门禁修复(BUG-543)
|
||||
|
||||
Gitea run 2408:`validate` 通过,`publish` 在 `railway-web.Dockerfile` `RUN npm run build` 失败。报错 `Failed to fetch Inter from Google Fonts`。根因是 BUG-430 的 `next/font/google` 在镜像构建里访问不到 Google。未改 workflow。
|
||||
|
||||
| 项 | 原值 | 新值 | 原因 |
|
||||
| --- | --- | --- | --- |
|
||||
| `site-style-isolation-contract` Inter 加载断言 | `import { Inter } from "next/font/google"` | `import localFont from "next/font/local"` + 仓内 woff2 魔数 + `frontend/src` 禁止 `from "next/font/google"` / `fonts.googleapis.com` | 构建期不得出网拉字体 |
|
||||
|
||||
本机补充:`npx tsx --test tests/site-style-isolation-contract.test.ts` **4/4**;`tsc --noEmit` 0 错;改动文件 eslint 0 error。本机 `npm run build` 被 worktree 里 `frontend/node_modules` 指向仓外的 symlink 挡住(Turbopack `points out of the filesystem root`),属既有环境缺口;CI publish 镜像内是 `npm ci`,无此 symlink。编号:BUG-543(未占用预留的 BUG-542)。未改 `.gitea/workflows/**`。
|
||||
|
||||
Reference in New Issue
Block a user