iter(g28): 浮层 Esc 逐层关闭,阻止冒泡连带关外层

This commit is contained in:
HIsheR
2026-10-26 11:38:44 +08:00
parent b263075e65
commit d9feeda0fd
10 changed files with 33 additions and 12 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ function openViewer(src: string, alt?: string): void {
document.removeEventListener('keydown', onKey);
prev?.focus?.();
};
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && close();
const onKey = (e: KeyboardEvent) => { if (e.key !== 'Escape') return; e.stopPropagation(); close(); }; // 预览层 Esc 自关,不连带关外层
mask.addEventListener('click', close);
document.addEventListener('keydown', onKey);
document.body.appendChild(mask);