From cd06a5580eea7a0ce82e7956e014039e850fd617 Mon Sep 17 00:00:00 2001 From: Orion Date: Fri, 11 Sep 2026 08:55:14 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=8A=AB=E9=9C=B2=E4=B8=8E=E6=BB=9A=E5=8A=A8=E9=94=81?= =?UTF-8?q?=E6=89=80=E6=9C=89=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复记录详情中的渐进式二维码与 wget 展示,并确保详情切换时重置披露状态。为滚动锁引入按所有者释放机制,避免重复或错误释放解锁仍打开的抽屉。 - 二维码和 wget 命令默认折叠,改为可操作的显示控件 - 详情关闭按钮保持 44px 触控目标,嵌套对话框 Escape 不穿透 - 增加 scrollLock mocked document 回归测试 - 已通过类型检查、架构检查、生产构建和 Node 测试 --- .../common/SentRecordDetailModal.vue | 27 ++++++++++++++----- src/components/common/SideDrawer.vue | 9 ++++--- src/components/common/scrollLock.ts | 19 +++++++------ tests/scrollLock.test.mjs | 27 +++++++++++++++++++ 4 files changed, 65 insertions(+), 17 deletions(-) create mode 100644 tests/scrollLock.test.mjs diff --git a/src/components/common/SentRecordDetailModal.vue b/src/components/common/SentRecordDetailModal.vue index 584b167..cbefc44 100644 --- a/src/components/common/SentRecordDetailModal.vue +++ b/src/components/common/SentRecordDetailModal.vue @@ -30,7 +30,7 @@ type="button" aria-label="关闭文件详情" @click="emit('close')" - class="rounded-[30px] p-1.5 transition-colors hover:bg-gray-100 dark:hover:bg-gray-800 sm:p-2" + class="min-h-11 min-w-11 rounded-[30px] p-1.5 transition-colors hover:bg-gray-100 dark:hover:bg-gray-800 sm:p-2" >

- 点击复制 wget 命令 +

+

{{ wgetCommand }}

@@ -156,8 +158,10 @@ type="button" class="bg-white p-3 sm:p-4 rounded-lg shadow-sm mb-3 sm:mb-4" aria-label="取件二维码" + @click="showQr = !showQr" > - + 显示二维码 +

() const modalTitleId = 'sent-record-detail-title' let returnFocusElement: HTMLElement | null = null +let scrollLockOwner: ReturnType | null = null +const showQr = ref(false) +const showWget = ref(false) +const wgetCommand = computed(() => `wget ${buildAbsoluteUrl(`/share/select?code=${props.record?.retrieveCode ?? ''}`)} -O "${props.record?.filename ?? ''}"`) const focusableSelector = 'button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])' const handleKeydown = (event: KeyboardEvent) => { if (event.key === 'Escape') { event.preventDefault(); emit('close'); return } @@ -232,14 +241,20 @@ const handleKeydown = (event: KeyboardEvent) => { } } watch(() => props.record, async (record) => { + if (scrollLockOwner) { + unlockBodyScroll(scrollLockOwner) + scrollLockOwner = null + } + showQr.value = false + showWget.value = false if (record) { returnFocusElement = document.activeElement instanceof HTMLElement ? document.activeElement : null - lockBodyScroll(); await nextTick(); modalRef.value?.focus() + scrollLockOwner = lockBodyScroll(); await nextTick(); modalRef.value?.focus() } else { - unlockBodyScroll(); await nextTick(); returnFocusElement?.focus(); returnFocusElement = null + await nextTick(); returnFocusElement?.focus(); returnFocusElement = null } }, { immediate: true }) -onBeforeUnmount(() => { unlockBodyScroll(); returnFocusElement = null }) +onBeforeUnmount(() => { unlockBodyScroll(scrollLockOwner); scrollLockOwner = null; returnFocusElement = null })