mirror of
https://github.com/usememos/memos.git
synced 2025-01-31 09:37:51 +08:00
fix: inject additional style and scripts
This commit is contained in:
parent
58429f88a0
commit
416e07cb1f
1 changed files with 6 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue