mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
fix: inject additional style and scripts
This commit is contained in:
@ -59,7 +59,6 @@ const App = () => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Inject additional style and script codes.
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (systemStatus.additionalStyle) {
|
if (systemStatus.additionalStyle) {
|
||||||
const styleEl = document.createElement("style");
|
const styleEl = document.createElement("style");
|
||||||
@ -67,17 +66,22 @@ const App = () => {
|
|||||||
styleEl.setAttribute("type", "text/css");
|
styleEl.setAttribute("type", "text/css");
|
||||||
document.body.insertAdjacentElement("beforeend", styleEl);
|
document.body.insertAdjacentElement("beforeend", styleEl);
|
||||||
}
|
}
|
||||||
|
}, [systemStatus.additionalStyle]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
if (systemStatus.additionalScript) {
|
if (systemStatus.additionalScript) {
|
||||||
const scriptEl = document.createElement("script");
|
const scriptEl = document.createElement("script");
|
||||||
scriptEl.innerHTML = systemStatus.additionalScript;
|
scriptEl.innerHTML = systemStatus.additionalScript;
|
||||||
document.head.appendChild(scriptEl);
|
document.head.appendChild(scriptEl);
|
||||||
}
|
}
|
||||||
|
}, [systemStatus.additionalScript]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
// dynamic update metadata with customized profile.
|
// dynamic update metadata with customized profile.
|
||||||
document.title = systemStatus.customizedProfile.name;
|
document.title = systemStatus.customizedProfile.name;
|
||||||
const link = document.querySelector("link[rel~='icon']") as HTMLLinkElement;
|
const link = document.querySelector("link[rel~='icon']") as HTMLLinkElement;
|
||||||
link.href = systemStatus.customizedProfile.logoUrl || "/logo.webp";
|
link.href = systemStatus.customizedProfile.logoUrl || "/logo.webp";
|
||||||
}, [systemStatus]);
|
}, [systemStatus.customizedProfile]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.documentElement.setAttribute("lang", locale);
|
document.documentElement.setAttribute("lang", locale);
|
||||||
|
Reference in New Issue
Block a user