diff --git a/.gitignore b/.gitignore index d0adddb5..d643c797 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ dist-ssr *.sln *.sw? /db/ +/release/ diff --git a/src/main.tsx b/src/main.tsx index 655c03b7..d70db15b 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -21,14 +21,12 @@ function useWindowWidth() { const newWidth = window.innerWidth; const newIsMobile = newWidth < 768; const now = Date.now(); - - // If we've already switched once, don't switch again for a very long time + if (hasSwitchedOnce.current && (now - lastSwitchTime.current) < 10000) { setWidth(newWidth); return; } - - // Only switch if we're actually crossing the threshold AND enough time has passed + if (newIsMobile !== isCurrentlyMobile.current && (now - lastSwitchTime.current) > 5000) { lastSwitchTime.current = now; isCurrentlyMobile.current = newIsMobile; @@ -38,7 +36,7 @@ function useWindowWidth() { } else { setWidth(newWidth); } - }, 2000); // Even longer debounce + }, 2000); }; window.addEventListener("resize", handleResize); @@ -54,8 +52,12 @@ function useWindowWidth() { function RootApp() { const width = useWindowWidth(); const isMobile = width < 768; - - // Use a stable key to prevent unnecessary remounting + const isElectron = (window as any).IS_ELECTRON === true || (window as any).electronAPI?.isElectron === true; + + if (isElectron) { + return ; + } + return isMobile ? : ; }