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(); const query = new URLSearchParams(params).toString();
img.src = `${__global_data.site}/@${name}?${query}`; const imgSrc = `${__global_data.site}/@${name}?${query}`;
code.textContent = img.src; img.src = imgSrc
code.style.visibility = 'visible';
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)); }, 500));
code.addEventListener('click', (e) => { code.addEventListener('click', (e) => {