Skip to content

Commit

Permalink
🚸 Feat: replace localStorage with sessionStorage for FixIt auto bookmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Jun 4, 2024
1 parent 4c9e20b commit cbde3f0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assets/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit cbde3f0

Please sign in to comment.