feat: fix custom JS doesn't reload after refresh bug (#2773)

This commit is contained in:
DacongDA
2024-03-05 15:03:25 +08:00
committed by GitHub
parent 11dbd5ba9a
commit fc137b9f76

View File

@ -14,9 +14,11 @@
import {useEffect} from "react";
let customHeadLoaded = false;
function CustomHead(props) {
useEffect(() => {
if (!sessionStorage.getItem("customHead")) {
if (!customHeadLoaded) {
const suffix = new Date().getTime().toString();
if (!props.headerHtml) {return;}
@ -40,7 +42,7 @@ function CustomHead(props) {
}
document.head.appendChild(innerNode);
});
sessionStorage.setItem("customHead", "true");
customHeadLoaded = true;
}
});
}