From cbde3f08985d947e587f5768fc481e5b320d19ec Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Tue, 4 Jun 2024 15:23:29 +0800 Subject: [PATCH] :children_crossing: Feat: replace localStorage with sessionStorage for FixIt auto bookmark --- assets/js/theme.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/theme.js b/assets/js/theme.js index edc87c49..84a9e578 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -1039,9 +1039,9 @@ class FixIt { return; } window.addEventListener('beforeunload', () => { - window.localStorage?.setItem(`fixit-bookmark/#${location.pathname}`, this.util.getScrollTop()); + window.sessionStorage?.setItem(`fixit-bookmark/#${location.pathname}`, this.util.getScrollTop()); }); - const scrollTop = Number(window.localStorage?.getItem(`fixit-bookmark/#${location.pathname}`)); + const scrollTop = Number(window.sessionStorage?.getItem(`fixit-bookmark/#${location.pathname}`)); // If the page opens with a specific hash, just jump out if (scrollTop && location.hash === '') { window.scrollTo({