From e22b54d3fc9f9b019f183001f58389144c9a549e Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Mon, 16 Dec 2024 21:24:29 +0800 Subject: [PATCH] feat: customLogo & customDesc --- src/components/Header.tsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 2ac896c..62f10f0 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -23,6 +23,23 @@ function Header() { const siteName = settingData?.data?.site_name + // @ts-expect-error CustomLogo is a global variable + const customLogo = window.CustomLogo || "/apple-touch-icon.png" + + // @ts-expect-error CustomDesc is a global variable + const customDesc = window.CustomDesc || t("nezha") + + useEffect(() => { + const link = document.querySelector("link[rel*='icon']") || document.createElement("link") + // @ts-expect-error set link.type + link.type = "image/x-icon" + // @ts-expect-error set link.rel + link.rel = "shortcut icon" + // @ts-expect-error set link.href + link.href = customLogo + document.getElementsByTagName("head")[0].appendChild(link) + }, [customLogo]) + useEffect(() => { document.title = siteName || "哪吒监控 Nezha Monitoring" }, [siteName]) @@ -39,7 +56,7 @@ function Header() { width={40} height={40} alt="apple-touch-icon" - src={"/apple-touch-icon.png"} + src={customLogo} className="relative m-0! border-2 border-transparent h-6 w-6 object-cover object-top p-0!" /> @@ -49,7 +66,7 @@ function Header() { siteName || "NEZHA" )} -

{t("nezha")}

+

{customDesc}