From b18d019a2e424bcc129778b52f695bec3454b7c2 Mon Sep 17 00:00:00 2001 From: wait4xx Date: Sun, 25 Oct 2026 20:24:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(terminal):=20/en/terminal=20=E5=8F=8C?= =?UTF-8?q?=E8=AF=AD=E8=96=84=E5=A3=B3=E2=80=94=E2=80=94=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA=E9=9B=B6=E5=88=86=E5=8F=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - terminal.astro 抽 locale prop:frontmatter 静态文案 + script 层 zh/en 双 DICT(命令描述/ls 路由表/whoami/exit 目标),双轨共享 一份 chunk;路径守卫 Set{/terminal,/en/terminal} - en/terminal.astro 四行薄壳 - Keyboard 帮助表 terminal 词条按 /en/ 前缀改写(其余表格文案 双语化留给独立车道,注释已标) 车道:op-artalk(自验 15/15);收编验收 build+双轨 playwright 过—— 首验 FAIL 系验收方误用 textContent 吞了内联脚本中文注释,innerText 复核零中文,非车道缺陷 验证: pnpm astro build 30 页 exit 0(双产物);双轨 playwright 验收 (en 可见文案零中文/ls en 路由表/zh 回归/Keyboard 词条)全过 Spec: none (页型双语薄壳,车道级小活) Co-authored-by: GLM-5.3 --- src/components/geek/Keyboard.astro | 6 +- src/pages/en/terminal.astro | 6 ++ src/pages/terminal.astro | 133 +++++++++++++++++++++-------- 3 files changed, 110 insertions(+), 35 deletions(-) create mode 100644 src/pages/en/terminal.astro diff --git a/src/components/geek/Keyboard.astro b/src/components/geek/Keyboard.astro index 4a80b6d..2868976 100644 --- a/src/components/geek/Keyboard.astro +++ b/src/components/geek/Keyboard.astro @@ -21,7 +21,7 @@ const routes: Record = { g a文章 g g图库 g m瞬间 - /terminal终端彩蛋 + /terminal终端彩蛋 Esc关闭浮层 @@ -33,6 +33,10 @@ const routes: Record = { // 路由表由 data-routes 注入(module 脚本里 currentScript 恒为 null,不能走内联取参) const helpEl = document.getElementById('kbd-help') as HTMLElement & { dataset: { routes?: string } }; const routes: Record = JSON.parse(helpEl?.dataset.routes ?? '{}'); + // en 轨仅切换终端行词条(帮助表其余文案的双语化另行车道) + if (location.pathname === '/en' || location.pathname.startsWith('/en/')) { + document.querySelector('.k-term-desc')?.replaceChildren(document.createTextNode('terminal')); + } let chord = ''; let chordTimer: number | undefined; diff --git a/src/pages/en/terminal.astro b/src/pages/en/terminal.astro new file mode 100644 index 0000000..097aade --- /dev/null +++ b/src/pages/en/terminal.astro @@ -0,0 +1,6 @@ +--- +// en 轨薄壳:复用 /terminal 全部实现,仅切 locale(文案源见 terminal.astro 的 DICT) +import TerminalPage from '../terminal.astro'; +--- + + diff --git a/src/pages/terminal.astro b/src/pages/terminal.astro index 0735b58..e03a206 100644 --- a/src/pages/terminal.astro +++ b/src/pages/terminal.astro @@ -3,10 +3,32 @@ // 命令注册表唯一事实源;输出一律 DOM API + textContent(无 innerHTML,XSS 纪律) // 实现集提炼自 Phase 5b 预研(satnaing/terminal-portfolio 实读 + CodeNerve 反例) import BaseLayout from '../layouts/BaseLayout.astro'; + +interface Props { + locale?: 'zh' | 'en'; +} +const { locale = 'zh' } = Astro.props; + +// 静态层文案(script 层另有一套 dict,由 data-locale 运行时选取) +const T = locale === 'en' + ? { + desc: "wait4x's terminal easter egg: type help to explore", + welcome: 'wait4x terminal v1.0 —— type help to list available commands', + noscript: 'This easter egg needs JavaScript: the site is static with no runtime framework; this page is the only exception.', + aria_shell: 'interactive terminal easter egg', + aria_input: 'terminal command input', + } + : { + desc: 'wait4x 的终端彩蛋:help 开始探索', + welcome: 'wait4x terminal v1.0 —— 键入 help 查看可用命令', + noscript: '此彩蛋需要 JavaScript:静态站无运行时框架,仅此页例外。', + aria_shell: '交互终端彩蛋', + aria_input: '终端命令输入', + }; --- - -
+ +