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 })