🐛 修复详情披露与滚动锁所有权
修复记录详情中的渐进式二维码与 wget 展示,并确保详情切换时重置披露状态。为滚动锁引入按所有者释放机制,避免重复或错误释放解锁仍打开的抽屉。 - 二维码和 wget 命令默认折叠,改为可操作的显示控件 - 详情关闭按钮保持 44px 触控目标,嵌套对话框 Escape 不穿透 - 增加 scrollLock mocked document 回归测试 - 已通过类型检查、架构检查、生产构建和 Node 测试
This commit is contained in:
1 parent
5ffee48d80
commit
cd06a5580e
4 files changed
+65
-17
No files matched your search
@@ -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"
|
||||
>
|
||||
<XIcon
|
||||
class="w-4 h-4 sm:w-5 sm:h-5"
|
||||
@@ -140,11 +140,13 @@
|
||||
</button>
|
||||
</div>
|
||||
<p
|
||||
v-if="!showWget"
|
||||
class="text-xs sm:text-sm font-mono break-all line-clamp-2"
|
||||
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-600']"
|
||||
>
|
||||
点击复制 wget 命令
|
||||
<button type="button" class="min-h-11 rounded-[30px] px-3 text-left hover:bg-gray-200 dark:hover:bg-gray-700" @click="showWget = true">显示 wget 命令</button>
|
||||
</p>
|
||||
<p v-else class="text-xs sm:text-sm font-mono break-all" :class="[isDarkMode ? 'text-gray-300' : 'text-gray-600']">{{ wgetCommand }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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"
|
||||
>
|
||||
<QRCode :value="qrValue" :size="140" level="M" class="sm:w-[160px] sm:h-[160px]" />
|
||||
<span v-if="!showQr" class="flex h-[140px] w-[140px] items-center justify-center text-sm text-gray-500 sm:h-[160px] sm:w-[160px]">显示二维码</span>
|
||||
<QRCode v-else :value="qrValue" :size="140" level="M" class="sm:w-[160px] sm:h-[160px]" />
|
||||
</button>
|
||||
<p
|
||||
class="text-xs sm:text-sm truncate max-w-full"
|
||||
@@ -199,6 +203,7 @@ import {
|
||||
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type { SentFileRecord } from '@/types'
|
||||
import { buildAbsoluteUrl } from '@/utils/share-url'
|
||||
import { lockBodyScroll, unlockBodyScroll } from './scrollLock'
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -221,6 +226,10 @@ const modalRef = ref<HTMLElement>()
|
||||
|
||||
const modalTitleId = 'sent-record-detail-title'
|
||||
let returnFocusElement: HTMLElement | null = null
|
||||
let scrollLockOwner: ReturnType<typeof lockBodyScroll> | 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 })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in new issue
Block a user