Skip to content

Commit

Permalink
加载完成后自动刷新以应对缓存和跳转问题
Browse files Browse the repository at this point in the history
  • Loading branch information
FeignClaims committed Jan 31, 2024
1 parent 4847bd7 commit d0560c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
8 changes: 8 additions & 0 deletions docs/_static/no_cache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
window.addEventListener("load", (event) => {
if (window.localStorage) {
if (!localStorage.getItem("firstLoad")) {
localStorage["firstLoad"] = true;
setTimeout(() => window.location.reload(), 3000);
} else localStorage.removeItem("firstLoad");
}
});
13 changes: 1 addition & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,4 @@
def setup(app):
app.add_css_file("custom.css")
app.add_css_file("monofont.css")

FORCE_RELOAD_JS = """
(function () {
if (window.localStorage) {
if (!localStorage.getItem("firstLoad")) {
localStorage["firstLoad"] = true;
window.location.reload();
} else localStorage.removeItem("firstLoad");
}
})();
"""
app.add_js_file(None, body=FORCE_RELOAD_JS)
app.add_js_file("no_cache.js")

0 comments on commit d0560c9

Please sign in to comment.