🚸 Feat: replace localStorage with sessionStorage for FixIt auto bookmark

This commit is contained in:
Cell
2024-06-04 15:23:29 +08:00
parent 4c9e20b377
commit cbde3f0898
+2 -2
View File
@@ -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({