mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
fix: fix duplicated load bug of custom JS (#2771)
This commit is contained in:
parent
19942a8bd4
commit
11dbd5ba9a
@ -16,6 +16,7 @@ import {useEffect} from "react";
|
|||||||
|
|
||||||
function CustomHead(props) {
|
function CustomHead(props) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!sessionStorage.getItem("customHead")) {
|
||||||
const suffix = new Date().getTime().toString();
|
const suffix = new Date().getTime().toString();
|
||||||
|
|
||||||
if (!props.headerHtml) {return;}
|
if (!props.headerHtml) {return;}
|
||||||
@ -39,14 +40,8 @@ function CustomHead(props) {
|
|||||||
}
|
}
|
||||||
document.head.appendChild(innerNode);
|
document.head.appendChild(innerNode);
|
||||||
});
|
});
|
||||||
|
sessionStorage.setItem("customHead", "true");
|
||||||
return () => {
|
|
||||||
for (const el of document.head.children) {
|
|
||||||
if (el.getAttribute("app-custom-head" + suffix) !== null) {
|
|
||||||
document.head.removeChild(el);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user