fix wallpaper defaults

This commit is contained in:
or-else
2026-01-16 11:51:42 +03:00
parent 8c3d273c34
commit 16489432cf
22 changed files with 237 additions and 129 deletions
+20
View File
@@ -254,3 +254,23 @@ export function defaultWallpaper() {
const wp = wallpaperIndex[WALLPAPER_DEFAULTS.type][WALLPAPER_DEFAULTS.index];
return {name: `../${WALLPAPER_DEFAULTS.path}${wp.name}`, size: wp.size};
}
export function wallpaperNameFromUrl(wallpaperUrl) {
// Get filename from URL.
const parts = wallpaperUrl.split('/');
return parts[parts.length - 1];
}
export function wallpaperTypeFromUrl(wallpaperUrl) {
// Get filename from URL.
const fname = wallpaperNameFromUrl(wallpaperUrl);
const wallpaperIndex = require('../../img/bkg/index.json');
for (const type in wallpaperIndex) {
for (let i = 0; i < wallpaperIndex[type].length; i++) {
if (wallpaperIndex[type][i].name == fname) {
return type;
}
}
}
return null;
}