fix: handle empty custom textures (#2221)

This commit is contained in:
Huang Xin
2025-10-14 02:08:22 +08:00
committed by GitHub
parent 6de10c6c3b
commit 9a991a31ba
+8 -11
View File
@@ -47,20 +47,17 @@ const Providers = ({ children }: { children: React.ReactNode }) => {
if (appService.hasScreenBrightness && brightness >= 0) {
setScreenBrightness(brightness / 100);
}
const backgroundTextureId = globalViewSettings.backgroundTextureId;
const backgroundOpacity = globalViewSettings.backgroundOpacity;
const backgroundSize = globalViewSettings.backgroundSize;
if (backgroundTextureId && backgroundTextureId !== 'none') {
const customTexture = settings.customTextures.find((t) => t.id === backgroundTextureId);
const textureId = globalViewSettings.backgroundTextureId;
const textureOpacity = globalViewSettings.backgroundOpacity;
const textureSize = globalViewSettings.backgroundSize;
if (textureId && textureId !== 'none') {
document.documentElement.style.setProperty('--bg-texture-opacity', `${textureOpacity}`);
document.documentElement.style.setProperty('--bg-texture-size', textureSize);
const customTexture = settings.customTextures?.find((t) => t.id === textureId);
if (customTexture) {
addTexture(customTexture.path);
}
applyTexture(envConfig, backgroundTextureId);
document.documentElement.style.setProperty(
'--bg-texture-opacity',
backgroundOpacity.toString(),
);
document.documentElement.style.setProperty('--bg-texture-size', backgroundSize);
applyTexture(envConfig, textureId);
}
});
}