|
@@ -46,11 +46,17 @@ function App() {
|
|
|
dispatch({ type: 'setOrientation', params: { orientation: orientationType } })
|
|
|
}
|
|
|
handleOrientationChange()
|
|
|
+ function handlePopstate () {
|
|
|
+ window.history.pushState(null, '');
|
|
|
+ }
|
|
|
+ handlePopstate()
|
|
|
// 添加事件监听器
|
|
|
window.addEventListener("resize", handleOrientationChange);
|
|
|
+ window.addEventListener("popstate", handlePopstate);
|
|
|
// 组件卸载时移除事件监听器
|
|
|
return () => {
|
|
|
window.removeEventListener("resize", handleOrientationChange);
|
|
|
+ window.removeEventListener("popstate", handlePopstate);
|
|
|
};
|
|
|
}, [])
|
|
|
|