From 7038145d098b7583e18fb5dbc41b0eeb87cd4085 Mon Sep 17 00:00:00 2001 From: AdingApkgg Date: Fri, 26 Dec 2025 15:28:15 +0800 Subject: [PATCH 1/2] 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 } } }) From 80ea9774d90a04a653acc5710af39016e93d1870 Mon Sep 17 00:00:00 2001 From: AdingApkgg Date: Fri, 26 Dec 2025 18:56:28 +0800 Subject: [PATCH 2/2] Remove voice actor section from VndbPanel.vue and refactor related logic - Eliminated the voice actor display section to streamline the component. - Updated image loading logic to focus on screenshot handling within the current panel. - Adjusted the layout and state management for improved clarity and performance. --- src/components/VndbPanel.vue | 82 +++++------------------------------- 1 file changed, 10 insertions(+), 72 deletions(-) diff --git a/src/components/VndbPanel.vue b/src/components/VndbPanel.vue index bd5d95c..d8e3cde 100644 --- a/src/components/VndbPanel.vue +++ b/src/components/VndbPanel.vue @@ -319,58 +319,6 @@ - -
-
- -

角色配音

- ({{ searchStore.vndbInfo.va.length }}) -
- -
@@ -453,7 +401,7 @@ loading="lazy" @load="($event.target as HTMLElement).parentElement?.querySelector('.skeleton')?.classList.add('hidden')" /> -
+
@@ -611,7 +559,6 @@ import { Minimize2, X, Tag, - Mic, Link2, GitBranch, Globe, @@ -687,7 +634,6 @@ const screenshotsReady = ref(false) // 展开/收起状态 const expandedSections = ref({ names: false, - va: false, relations: false, characters: false, quotes: false, @@ -756,7 +702,6 @@ watch(() => searchStore.vndbInfo, async (newInfo) => { // 重置展开状态 expandedSections.value = { names: false, - va: false, relations: false, characters: false, quotes: false, @@ -772,13 +717,15 @@ watch(() => searchStore.vndbInfo, async (newInfo) => { nextTick(() => { // 延迟一帧确保 DOM 已渲染 requestAnimationFrame(() => { - // 查找截图区域的图片(通过 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 + // 在当前面板内查找截图图片 + const screenshotImgs = modalRef.value?.querySelectorAll('img[alt*="截图"]') + if (screenshotImgs) { + for (let i = 0; i < screenshotImgs.length; i++) { + const img = screenshotImgs[i] as HTMLImageElement + if (img.complete && img.naturalHeight > 0) { + screenshotsReady.value = true + break + } } } }) @@ -1030,15 +977,6 @@ function openGallery(startIndex: number) { } } -// 根据角色ID获取角色图片 -function getCharacterImage(characterId: string | undefined): string | undefined { - if (!characterId) { - return undefined - } - const char = characters.value.find(c => c.id === characterId) - return char?.image -} - // 格式化性别 function formatSex(sex: string): string { const sexMap: Record = {