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:
parent
466bb1245a
commit
b6e0ef1c3c
1 changed files with 18 additions and 4 deletions
|
|
@ -1053,15 +1053,29 @@ function applyTheme(rgb) {
|
||||||
|
|
||||||
const albumArtEl = document.getElementById('albumArt');
|
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() {
|
function fetchTheme() {
|
||||||
fetch('http://127.0.0.1:8765/current')
|
fetch('http://127.0.0.1:8765/current')
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(d => {
|
.then(d => {
|
||||||
if (d.rgb) applyTheme(d.rgb);
|
if (d.rgb) applyTheme(d.rgb);
|
||||||
if (d.art_url) {
|
if (d.art_url) setAlbumArt(d.art_url);
|
||||||
albumArtEl.style.backgroundImage = `url('${d.art_url}')`;
|
|
||||||
albumArtEl.style.opacity = '1';
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue