From fc137b9f76fbbc3032150600d26903e4b72e759e Mon Sep 17 00:00:00 2001 From: DacongDA Date: Tue, 5 Mar 2024 15:03:25 +0800 Subject: [PATCH] feat: fix custom JS doesn't reload after refresh bug (#2773) --- web/src/basic/CustomHead.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/src/basic/CustomHead.js b/web/src/basic/CustomHead.js index 6578a863..c0f9d538 100644 --- a/web/src/basic/CustomHead.js +++ b/web/src/basic/CustomHead.js @@ -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; } }); }