1
0
mirror of https://github.com/journey-ad/Moe-Counter.git synced 2024-11-27 17:00:51 +01:00

feat(web): show message on error

This commit is contained in:
roffy3051 2024-10-21 00:58:30 +08:00
parent 41bf6caeb8
commit 97c529e540

View File

@ -31,11 +31,25 @@
}
const query = new URLSearchParams(params).toString();
img.src = `${__global_data.site}/@${name}?${query}`;
code.textContent = img.src;
code.style.visibility = 'visible';
const imgSrc = `${__global_data.site}/@${name}?${query}`;
img.src = imgSrc
img.onload = () => img.scrollIntoView({ block: 'start', behavior: 'smooth' });
img.onload = () => {
img.scrollIntoView({ block: 'start', behavior: 'smooth' });
code.textContent = imgSrc;
code.style.visibility = 'visible';
}
img.onerror = () => {
fetch(imgSrc)
.then(async (res) => {
if (!res.ok) {
const { message } = await res.json();
alert(message);
}
})
};
}, 500));
code.addEventListener('click', (e) => {