修复:豆瓣图裂问题

This commit is contained in:
xqw8889
2025-11-11 22:20:54 +08:00
parent 6fb7be9036
commit 7d02a08c2d
3 changed files with 62 additions and 16 deletions
+19
View File
@@ -84,3 +84,22 @@ function Return() {
$('curtain').style.display = "none";
$('lightbox').innerHTML = "";
}
// 处理图片加载失败的函数
function handleImageError(img, currentSrc) {
if (!currentSrc.includes('doubanio.com')) {
return;
}
const domainList = ['img1.doubanio.com', 'img2.doubanio.com', 'img3.doubanio.com', 'img9.doubanio.com']; // 备用域名列表
let index = 0;
function tryNextDomain() {
if (index >= domainList.length) {
return;
}
img.src = currentSrc.replace(/https:\/\/[a-zA-Z0-9.-]+\.doubanio\.com/, `https://${domainList[index]}`);
img.onload = () => {
img.onload = img.onerror = null;
};
img.onerror = tryNextDomain;
}
tryNextDomain();
}