🐛 修复详情披露与滚动锁所有权

修复记录详情中的渐进式二维码与 wget 展示,并确保详情切换时重置披露状态。为滚动锁引入按所有者释放机制,避免重复或错误释放解锁仍打开的抽屉。

- 二维码和 wget 命令默认折叠,改为可操作的显示控件
- 详情关闭按钮保持 44px 触控目标,嵌套对话框 Escape 不穿透
- 增加 scrollLock mocked document 回归测试
- 已通过类型检查、架构检查、生产构建和 Node 测试
This commit is contained in:
orion committed 2026-09-11 08:55:28 +08:00
1 parent 5ffee48d80
commit cd06a5580e
4 files changed
+65 -17

No files matched your search

+6 -3
View File
@@ -57,11 +57,13 @@ const { t } = useI18n()
const isDarkMode = inject('isDarkMode')
const drawerRef = ref<HTMLElement>()
let returnFocusElement: HTMLElement | null = null
let scrollLockOwner: ReturnType<typeof lockBodyScroll> | null = null
const focusableSelector =
'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
const handleKeydown = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
if (event.target !== event.currentTarget && (event.target as HTMLElement).closest('[role="dialog"]') !== event.currentTarget) return
event.preventDefault()
emit('close')
return
@@ -84,20 +86,21 @@ watch(
() => props.visible,
async (visible) => {
if (visible) {
lockBodyScroll()
scrollLockOwner = lockBodyScroll()
returnFocusElement = document.activeElement instanceof HTMLElement ? document.activeElement : null
await nextTick()
const first = drawerRef.value?.querySelector<HTMLElement>(focusableSelector)
;(first || drawerRef.value)?.focus()
} else {
unlockBodyScroll()
unlockBodyScroll(scrollLockOwner)
scrollLockOwner = null
await nextTick()
returnFocusElement?.focus()
returnFocusElement = null
}
}
)
onBeforeUnmount(() => unlockBodyScroll())
onBeforeUnmount(() => { unlockBodyScroll(scrollLockOwner); scrollLockOwner = null })
</script>
<style scoped>