Fix Library theme file path encoding - proper URI encoding for special characters and consistent file:// protocol usage
This commit is contained in:
parent
9d94fb8695
commit
2a27dee37b
15
index.html
15
index.html
|
|
@ -1458,19 +1458,22 @@
|
|||
const randomImage = allImages[randomIndex];
|
||||
|
||||
if (randomImage) {
|
||||
// Use different approaches for file paths based on environment
|
||||
// Properly encode the file path for CSS url()
|
||||
let imageUrl;
|
||||
if (window.electronAPI) {
|
||||
// In Electron, use the path as-is (Electron handles file protocol internally)
|
||||
imageUrl = randomImage.path;
|
||||
// In Electron, we need to properly encode the path for CSS
|
||||
// Convert backslashes to forward slashes and encode special characters
|
||||
const normalizedPath = randomImage.path.replace(/\\/g, '/');
|
||||
// Use file:// protocol and encode the path
|
||||
imageUrl = `file:///${encodeURI(normalizedPath)}`;
|
||||
} else {
|
||||
// In browser, use file protocol (though this may not work due to security restrictions)
|
||||
const cleanPath = randomImage.path.replace(/\\/g, '/');
|
||||
imageUrl = `file:///${cleanPath}`;
|
||||
imageUrl = `file:///${encodeURI(cleanPath)}`;
|
||||
}
|
||||
|
||||
element.style.backgroundImage = `url('${imageUrl}')`;
|
||||
console.log(`📸 Panel ${index + 1}: Using ${randomImage.name} from ${imageUrl}`);
|
||||
element.style.backgroundImage = `url("${imageUrl}")`;
|
||||
console.log(`📸 Panel ${index + 1}: Using ${randomImage.name} from ${randomImage.path}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue