From d00ca7e44720cdf33d2b3b1ce4baf261be6641fd Mon Sep 17 00:00:00 2001 From: wait4xx Date: Sun, 25 Oct 2026 22:19:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(i18n):=20=E8=AF=AD=E8=A8=80=E8=BD=A8?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E4=BF=AE=E5=A4=8D+=E9=87=8D=E6=8E=92?= =?UTF-8?q?=EF=BC=8C=E7=83=AD=E5=8A=9B=E5=9B=BE=E5=88=87=20GitHub=EF=BC=88?= =?UTF-8?q?=E8=BD=A6=E9=81=93=20E=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 真 bug(用户实测:切 en 后点板块回中文):Header nav href 硬编码 zh 路径,curLocale 只喂了词条——localeOf(Astro.url) 构建期自推断 +五项+品牌链接全轨化(brand 原指 / 同病同修),aria 同步 - 导航重排(用户拍板):开源 · 文章 · 图库 · 瞬间 · 关于;瞬间 新进导航;移动 320-430×双轨八格页面级溢出全 0(内滚阈值 350→450 +中段地板再收;en 390-430 尾部约 55px 靠内滚——'Open Source'→ 'Projects' 改名可省 35px,留用户拍板) - 热力图纯切 GitHub(用户拍板):GraphQL contributionsCollection 53 周窗口(上海日界);token=宿主 0600 github-token.txt,缺位→ WARN 降级样例数据(当前站点即样例);三级回落 token→样例→空网格 - E2E 新增 2 断言:en 页 nav 全 /en/ 前缀+brand 指 /en/(本 bug 的回归测试) 车道:op-gitea(自验 33/33);收编验收:en/zh 序实测+三宽度溢出 0+ E2E 33/33(本地 dist 口径——staging 未含未推代码为既定纪律) 验证: pnpm astro build 34 页 exit 0;node tests/e2e.mjs 33/33; en/zh 导航序与 href 前缀 playwright 实测 Spec: none (Header 修复+重排+热力图换源,车道级交付) Co-authored-by: GLM-5.3 --- src/components/Header.astro | 31 ++++--- src/data/heatmap-fallback.json | 2 +- src/i18n/ui.ts | 2 +- src/lib/heatmap.ts | 142 +++++++++++++++++++++------------ tests/e2e.mjs | 6 ++ 5 files changed, 120 insertions(+), 63 deletions(-) diff --git a/src/components/Header.astro b/src/components/Header.astro index b0253ad..5d028d9 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -2,26 +2,30 @@ import { localeOf, localePath } from '../lib/locale'; import { t } from '../i18n/ui'; -// 顶部导航:≤4 项纪律(防 higan 十项复发);当前页 aria-current +// 顶部导航:单行纪律 + 双语整轨(zh 无前缀 ↔ /en/,locale 构建期按页自推断—— +// 曾只把 locale 喂给词条/语言钮而 href 裸奔 zh 路径,en 页点导航全部跌回中文轨) const path = Astro.url.pathname; +const curLocale = localeOf(path); +const prefix = curLocale === 'en' ? '/en' : ''; const isCurrent = (href: string) => path === href || path === href.replace(/\/$/, '') || path.startsWith(href); -// 语言切换:同路径跨前缀跳转(zh 无前缀 ↔ /en/),预构建双语毫秒级 -const curLocale = localeOf(path); +// 顺序:开源 · 文章 · 图库 · 瞬间 · 关于(瞬间新进,开源前置) const nav = [ - { href: '/archives/', label: t('nav_posts', curLocale) }, - { href: '/gallery/', label: t('nav_gallery', curLocale) }, - { href: '/about/', label: t('nav_about', curLocale) }, - { href: '/opensource/', label: t('nav_opensource', curLocale) }, + { href: `${prefix}/opensource/`, label: t('nav_opensource', curLocale) }, + { href: `${prefix}/archives/`, label: t('nav_posts', curLocale) }, + { href: `${prefix}/gallery/`, label: t('nav_gallery', curLocale) }, + { href: `${prefix}/moments/`, label: t('nav_moments', curLocale) }, + { href: `${prefix}/about/`, label: t('nav_about', curLocale) }, ]; +const homeHref = curLocale === 'en' ? '/en/' : '/'; const switchHref = localePath(path, curLocale === 'zh' ? 'en' : 'zh'); const switchLabel = curLocale === 'zh' ? 'EN' : '中'; ---