一分钟搭建影视站,支持Docker等部署方式
fix(image): 完善图片加载兜底逻辑
bestZwei7091e3fa17c6
diff --git a/js/app.js b/js/app.jsindex 2d22dac..fdcbfd8 100644--- a/js/app.js+++ b/js/app.js@@ -777,6 +777,7 @@ async function search() {// 修改为水平卡片布局,图片在左侧,文本在右侧,并优化样式const hasCover = item.vod_pic && item.vod_pic.startsWith('http');+ const imgCfg = hasCover ? buildImageProxyConfig(item.vod_pic) : null;return `<div class="card-hover bg-[#111] rounded-lg overflow-hidden cursor-pointer transition-all hover:scale-[1.02] h-full shadow-sm hover:shadow-md"@@ -784,9 +785,11 @@ async function search() {<div class="flex h-full">${hasCover ? `<div class="relative flex-shrink-0 search-card-img-container">- <img src="${item.vod_pic}" alt="${safeName}"+ <img src="${escapeHtmlAttr(imgCfg.primary)}" alt="${safeName}"class="h-full w-full object-cover transition-transform hover:scale-110"- onerror="this.onerror=null; this.src='https://via.placeholder.com/300x450?text=无封面'; this.classList.add('object-contain');"+ onerror="window.handleImageError(this)"+ data-fallback="${imgCfg.fallback}"+ data-placeholder="https://via.placeholder.com/300x450?text=无封面"loading="lazy"><div class="absolute inset-0 bg-gradient-to-r from-black/30 to-transparent"></div></div>` : ''}diff --git a/js/douban.js b/js/douban.jsindex 2aec3a0..c86bb0d 100644--- a/js/douban.js+++ b/js/douban.js@@ -47,12 +47,13 @@ window.handleImageError = function (img) {if (Array.isArray(arr) && arr.length) {img.src = arr.shift();img.setAttribute('data-fallback', encodeURIComponent(JSON.stringify(arr)));- } else {- img.onerror = null; // 链已耗尽,停止重试+ return;}- } catch (e) {- img.onerror = null;- }+ } catch (e) { /* 忽略 */ }+ // 兜底链已耗尽,使用最终占位图(若有),并停止重试避免死循环+ const ph = img.getAttribute('data-placeholder');+ if (ph) img.src = ph;+ img.onerror = null;};// 初始化「图片加载方式」设置项diff --git a/js/player.js b/js/player.jsindex a9e2c24..4ec4ad0 100644--- a/js/player.js+++ b/js/player.js@@ -1573,14 +1573,17 @@ async function showSwitchResourceModal() {const sourceName = resourceOptions.find(opt => opt.key === sourceKey)?.name || '未知资源';const speedResult = speedResults[sourceKey] || { speed: -1, error: '未测试' };+ const imgCfg = buildImageProxyConfig(result.vod_pic);html += `<div class="relative group ${isCurrentSource ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer hover:scale-105 transition-transform'}"${!isCurrentSource ? `onclick="switchToResource('${sourceKey}', '${result.vod_id}')"` : ''}><div class="aspect-[2/3] rounded-lg overflow-hidden bg-gray-800 relative">- <img src="${result.vod_pic}"+ <img src="${escapeHtmlAttr(imgCfg.primary)}"alt="${result.vod_name}"class="w-full h-full object-cover"- onerror="this.src='data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjNjY2IiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHJlY3QgeD0iMyIgeT0iMyIgd2lkdGg9IjE4IiBoZWlnaHQ9IjE4IiByeD0iMiIgcnk9IjIiPjwvcmVjdD48cGF0aCBkPSJNMjEgMTV2NGEyIDIgMCAwIDEtMiAySDVhMiAyIDAgMCAxLTItMnYtNCI+PC9wYXRoPjxwb2x5bGluZSBwb2ludHM9IjE3IDggMTIgMyA3IDgiPjwvcG9seWxpbmU+PHBhdGggZD0iTTEyIDN2MTIiPjwvcGF0aD48L3N2Zz4='">+ onerror="window.handleImageError(this)"+ data-fallback="${imgCfg.fallback}"+ data-placeholder="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjNjY2IiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHJlY3QgeD0iMyIgeT0iMyIgd2lkdGg9IjE4IiBoZWlnaHQ9IjE4IiByeD0iMiIgcnk9IjIiPjwvcmVjdD48cGF0aCBkPSJNMjEgMTV2NGEyIDIgMCAwIDEtMiAySDVhMiAyIDAgMCAxLTItMnYtNCI+PC9wYXRoPjxwb2x5bGluZSBwb2ludHM9IjE3IDggMTIgMyA3IDgiPjwvcG9seWxpbmU+PHBhdGggZD0iTTEyIDN2MTIiPjwvcGF0aD48L3N2Zz4="><!-- 速率显示在图片右上角 --><div class="absolute top-1 right-1 speed-badge bg-black bg-opacity-75">