mirror of
https://github.com/Moe-Sakura/frontend.git
synced 2026-04-04 08:25:07 +08:00
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.
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user