diff --git a/src/App.tsx b/src/App.tsx index 4866b31..f606f58 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -62,9 +62,7 @@ const App: React.FC = () => { i18n.changeLanguage(settingData?.data?.config?.language) } - const customMobileBackgroundImage = - // @ts-expect-error CustomMobileBackgroundImage is a global variable - (window.CustomMobileBackgroundImage as string) !== "" ? window.CustomMobileBackgroundImage : undefined + const customMobileBackgroundImage = window.CustomMobileBackgroundImage !== "" ? window.CustomMobileBackgroundImage : undefined return ( diff --git a/src/components/Header.tsx b/src/components/Header.tsx index e40524f..25cb100 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -41,6 +41,8 @@ function Header() { // @ts-expect-error CustomDesc is a global variable const customDesc = window.CustomDesc || t("nezha") + const customMobileBackgroundImage = window.CustomMobileBackgroundImage !== "" ? window.CustomMobileBackgroundImage : undefined + useEffect(() => { const link = document.querySelector("link[rel*='icon']") || document.createElement("link") // @ts-expect-error set link.type @@ -109,6 +111,7 @@ function Header() { onClick={handleBackgroundToggle} className={cn("rounded-full px-[9px] bg-white dark:bg-black", { "bg-white/70 dark:bg-black/70": customBackgroundImage, + "hidden sm:block": customMobileBackgroundImage, })} > diff --git a/src/hooks/use-background.ts b/src/hooks/use-background.ts index 1f70651..addcac0 100644 --- a/src/hooks/use-background.ts +++ b/src/hooks/use-background.ts @@ -3,6 +3,7 @@ import { useEffect, useState } from "react" declare global { interface Window { CustomBackgroundImage: string + CustomMobileBackgroundImage: string } }