From 416e07cb1fbca09700b8f0b05d4515a2dd92e3e8 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 12 Sep 2023 23:43:32 +0800 Subject: [PATCH] fix: inject additional style and scripts --- web/src/App.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web/src/App.tsx b/web/src/App.tsx index c0b04efa..30950217 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -59,7 +59,6 @@ const App = () => { } }, []); - // Inject additional style and script codes. useEffect(() => { if (systemStatus.additionalStyle) { const styleEl = document.createElement("style"); @@ -67,17 +66,22 @@ const App = () => { styleEl.setAttribute("type", "text/css"); document.body.insertAdjacentElement("beforeend", styleEl); } + }, [systemStatus.additionalStyle]); + + useEffect(() => { if (systemStatus.additionalScript) { const scriptEl = document.createElement("script"); scriptEl.innerHTML = systemStatus.additionalScript; document.head.appendChild(scriptEl); } + }, [systemStatus.additionalScript]); + useEffect(() => { // dynamic update metadata with customized profile. document.title = systemStatus.customizedProfile.name; const link = document.querySelector("link[rel~='icon']") as HTMLLinkElement; link.href = systemStatus.customizedProfile.logoUrl || "/logo.webp"; - }, [systemStatus]); + }, [systemStatus.customizedProfile]); useEffect(() => { document.documentElement.setAttribute("lang", locale);