fix: load album art via fetch+blob to bypass WebEngine URL restrictions

Direct background-image URLs to external hosts are blocked in the
local WebEngineView context; fetch the image as a blob and convert
to data URL instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ltadeu6 2026-06-07 10:30:14 -03:00
parent 466bb1245a
commit b6e0ef1c3c
No known key found for this signature in database
GPG key ID: FB9FDAB6B6F3418D

View file

@ -1053,15 +1053,29 @@ function applyTheme(rgb) {
const albumArtEl = document.getElementById('albumArt');
let lastArtUrl = '';
function setAlbumArt(url) {
if (!url || url === lastArtUrl) return;
lastArtUrl = url;
fetch(url)
.then(r => r.blob())
.then(blob => {
const reader = new FileReader();
reader.onload = () => {
albumArtEl.style.backgroundImage = `url('${reader.result}')`;
};
reader.readAsDataURL(blob);
})
.catch(() => {});
}
function fetchTheme() {
fetch('http://127.0.0.1:8765/current')
.then(r => r.json())
.then(d => {
if (d.rgb) applyTheme(d.rgb);
if (d.art_url) {
albumArtEl.style.backgroundImage = `url('${d.art_url}')`;
albumArtEl.style.opacity = '1';
}
if (d.art_url) setAlbumArt(d.art_url);
})
.catch(() => {});
}