From 7038145d098b7583e18fb5dbc41b0eeb87cd4085 Mon Sep 17 00:00:00 2001 From: AdingApkgg Date: Fri, 26 Dec 2025 15:28:15 +0800 Subject: [PATCH] Refactor image loading logic in VndbPanel.vue to enhance screenshot handling - Updated the logic to locate screenshots using the alt attribute for better accuracy. - Improved the condition to check if images are loaded and have valid dimensions before setting the screenshotsReady state. --- src/components/VndbPanel.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/VndbPanel.vue b/src/components/VndbPanel.vue index b54e4bb..bd5d95c 100644 --- a/src/components/VndbPanel.vue +++ b/src/components/VndbPanel.vue @@ -772,11 +772,13 @@ watch(() => searchStore.vndbInfo, async (newInfo) => { nextTick(() => { // 延迟一帧确保 DOM 已渲染 requestAnimationFrame(() => { - const vndbContent = document.querySelector('.vndb-content') - if (vndbContent) { - const firstScreenshot = vndbContent.querySelector('img[loading="lazy"]') as HTMLImageElement - if (firstScreenshot?.complete && firstScreenshot.naturalHeight > 0) { + // 查找截图区域的图片(通过 alt 属性特征定位) + const screenshotImgs = document.querySelectorAll('img[alt*="截图"]') + for (let i = 0; i < screenshotImgs.length; i++) { + const img = screenshotImgs[i] as HTMLImageElement + if (img.complete && img.naturalHeight > 0) { screenshotsReady.value = true + break } } })