fix(keyboard): g g chord 不可达——路由判断先于武装分支

Phase 1 潜伏缺陷:g 键分支先于路由检查 return,第二击 g 永远
重新武装,routes['g'](gallery)全站不可达。修序即愈,g→g 自身
是合法 chord。en 轨随上一提交前缀化后同步受益。

验证: chord 矩阵 5 检(zh/en × g g/g h/g m 实跳目标全中);
      E2E 31/31 PASS

Spec: none (keydown 分支修序,矩阵测试入档)

Co-authored-by: GLM-5.3
This commit is contained in:
wait4xandGLM-5.3 committed 2026-10-25 21:18:58 +08:00
1 parent 3e73fe957e
commit 71b8985c17
1 file changed
+9 -5
+9 -5
View File
@@ -67,15 +67,19 @@ const routes: Record<string, string> = {
(document.getElementById('kbd-help') as HTMLDialogElement | null)?.showModal();
return;
}
// 路由判断必须先于 g 武装分支:g→g 自身也是合法 chord(gallery),
// 原序里第二击 g 永远重新武装、routes['g'] 不可达——Phase 1 潜伏缺陷
// (g g 全站失灵实锤于 2026-10-25 矩阵测试)
if (chord === 'g' && routes[e.key]) {
location.href = routes[e.key]!;
chord = '';
clearTimeout(chordTimer);
return;
}
if (e.key === 'g') {
chord = 'g';
clearTimeout(chordTimer);
chordTimer = window.setTimeout(() => (chord = ''), 300);
return;
}
if (chord === 'g' && routes[e.key]) {
location.href = routes[e.key]!;
chord = '';
}
});
</script>