Skip to content

Commit

Permalink
监听浏览器popState事件, 修复通过浏览器前进, 后退按钮 不切换页面类型
Browse files Browse the repository at this point in the history
  • Loading branch information
maboloshi committed Feb 15, 2025
1 parent 8ae59ca commit b1187d2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions main.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,11 @@
pageConfig.firstChangeURL = true; // 页面开始切换前设置为 true
});

// 监听浏览器 history 切换
window.addEventListener('popstate', () => {
pageConfig.firstChangeURL = true; // 页面开始切换前设置为 true
});

// 监听 Turbo 完成事件(延迟翻译)
document.addEventListener('turbo:load', () => {
if (!pageConfig.currentPageType) return;
Expand Down

0 comments on commit b1187d2

Please sign in to comment.