From 7353d3e9d7a74665915b30a68c875d0a244d15b2 Mon Sep 17 00:00:00 2001 From: NriotHrreion Date: Thu, 6 Jun 2024 18:05:44 +0800 Subject: [PATCH] feat: Add "Sure you want to leave?" alert --- src/App.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/App.tsx b/src/App.tsx index 95c27e4..8b271e5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -50,6 +50,12 @@ const App: React.FC = () => { e.preventDefault(); }); + window.addEventListener("beforeunload", (e) => { + e.preventDefault(); + alert("确定要关闭此页面吗?"); + e.returnValue = ""; + }); + // To prevent some part of the page being covered by the bottom toolbar of mobile browsers if(Utils.isMobile()) { const { height } = Utils.getWindowConfig();