From c7d49c150404a407f6db3cd168cae03b6fa153d0 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Tue, 14 Oct 2025 01:04:45 +0800 Subject: [PATCH] fix: load custom texture before applying it (#2219) --- .../src/app/library/components/LibraryHeader.tsx | 2 +- apps/readest-app/src/components/Providers.tsx | 12 ++++++++---- apps/readest-app/src/components/WindowButtons.tsx | 2 +- .../src/components/settings/ColorPanel.tsx | 2 +- apps/readest-app/src/store/customTextureStore.ts | 15 ++++++++------- apps/readest-app/src/styles/globals.css | 1 - apps/readest-app/src/styles/textures.ts | 13 +++++-------- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/apps/readest-app/src/app/library/components/LibraryHeader.tsx b/apps/readest-app/src/app/library/components/LibraryHeader.tsx index 7e1ee795..1eb9ce1b 100644 --- a/apps/readest-app/src/app/library/components/LibraryHeader.tsx +++ b/apps/readest-app/src/app/library/components/LibraryHeader.tsx @@ -150,7 +150,7 @@ const LibraryHeader: React.FC = ({ onChange={handleSearchChange} spellCheck='false' className={clsx( - 'input rounded-badge bg-base-300/30 h-9 w-full pl-10 pr-10 sm:h-7', + 'input rounded-badge bg-base-300/45 h-9 w-full pl-10 pr-10 sm:h-7', 'font-sans text-sm font-light', 'border-none focus:outline-none focus:ring-0', )} diff --git a/apps/readest-app/src/components/Providers.tsx b/apps/readest-app/src/components/Providers.tsx index bf130987..acd9bb02 100644 --- a/apps/readest-app/src/components/Providers.tsx +++ b/apps/readest-app/src/components/Providers.tsx @@ -16,10 +16,10 @@ import { useCustomTextureStore } from '@/store/customTextureStore'; import { getLocale } from '@/utils/misc'; const Providers = ({ children }: { children: React.ReactNode }) => { - const { appService } = useEnv(); + const { envConfig, appService } = useEnv(); const { applyUILanguage } = useSettingsStore(); const { setScreenBrightness } = useDeviceControlStore(); - const { applyTexture } = useCustomTextureStore(); + const { addTexture, applyTexture } = useCustomTextureStore(); const iconSize = useDefaultIconSize(); useSafeAreaInsets(); // Initialize safe area insets @@ -51,7 +51,11 @@ const Providers = ({ children }: { children: React.ReactNode }) => { const backgroundOpacity = globalViewSettings.backgroundOpacity; const backgroundSize = globalViewSettings.backgroundSize; if (backgroundTextureId && backgroundTextureId !== 'none') { - applyTexture(backgroundTextureId); + const customTexture = settings.customTextures.find((t) => t.id === backgroundTextureId); + if (customTexture) { + addTexture(customTexture.path); + } + applyTexture(envConfig, backgroundTextureId); document.documentElement.style.setProperty( '--bg-texture-opacity', backgroundOpacity.toString(), @@ -60,7 +64,7 @@ const Providers = ({ children }: { children: React.ReactNode }) => { } }); } - }, [appService, applyUILanguage, applyTexture, setScreenBrightness]); + }, [envConfig, appService, applyUILanguage, applyTexture, setScreenBrightness]); // Make sure appService is available in all children components if (!appService) return; diff --git a/apps/readest-app/src/components/WindowButtons.tsx b/apps/readest-app/src/components/WindowButtons.tsx index 3abd68f3..18639c51 100644 --- a/apps/readest-app/src/components/WindowButtons.tsx +++ b/apps/readest-app/src/components/WindowButtons.tsx @@ -28,7 +28,7 @@ const WindowButton: React.FC = ({ onClick, label, id, childre