From 7716ce4001c1f4d222a6eb2f629ae12885233630 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Mon, 16 Mar 2026 12:45:32 +0800 Subject: [PATCH] Improve mobile navigation layout and behavior --- src/components/UnifiedNavigation.tsx | 167 +++++++++++++++++---------- 1 file changed, 103 insertions(+), 64 deletions(-) diff --git a/src/components/UnifiedNavigation.tsx b/src/components/UnifiedNavigation.tsx index 2eb9e6b..58e45ee 100644 --- a/src/components/UnifiedNavigation.tsx +++ b/src/components/UnifiedNavigation.tsx @@ -113,6 +113,22 @@ export default function UnifiedNavigation() { setAccountMenuOpen(false); }, [user]); + useEffect(() => { + setMenuOpen(false); + }, [pathname]); + + useEffect(() => { + if (typeof document === "undefined") { + return; + } + + document.body.style.overflow = menuOpen ? "hidden" : ""; + + return () => { + document.body.style.overflow = ""; + }; + }, [menuOpen]); + useEffect(() => { if (typeof window === "undefined") { return; @@ -167,13 +183,13 @@ export default function UnifiedNavigation() { const isHiddenRoute = pathname ? [ - "/login", - "/register", - "/xstream", - "/xcloudflow", - "/xscopehub", - "/blogs", - ].some((prefix) => pathname.startsWith(prefix)) + "/login", + "/register", + "/xstream", + "/xcloudflow", + "/xscopehub", + "/blogs", + ].some((prefix) => pathname.startsWith(prefix)) : false; if (isHiddenRoute) { @@ -197,10 +213,27 @@ export default function UnifiedNavigation() { }} className="sticky top-0 z-50 w-full border-b border-surface-border bg-background/95 text-text backdrop-blur transition-colors duration-150" > -
+
+ setMenuOpen(false)} + > + logo + + Cloud-Neutral + + -
@@ -219,33 +251,35 @@ export default function UnifiedNavigation() { {filteredMainNav.map((item) => { const active = isActive(item); if (item.showOn === "mobile") return null; - if (item.key === 'chat') { + if (item.key === "chat") { return ( - ) + ); } return ( {item.icon && } @@ -261,10 +295,11 @@ export default function UnifiedNavigation() { {item.icon && } @@ -285,7 +320,10 @@ export default function UnifiedNavigation() { onToggle={toggleChannel} variant="icon" /> - + @@ -426,7 +467,7 @@ export default function UnifiedNavigation() {
)} -
+

{isChinese ? "主导航" : "Main Navigation"}

@@ -434,7 +475,7 @@ export default function UnifiedNavigation() { {filteredMainNav.map((item) => { const active = isActive(item); if (item.showOn === "desktop") return null; - if (item.key === 'chat') { + if (item.key === "chat") { return ( - ) + ); } return ( setMenuOpen(false)} > {item.icon && ( )} - - {getLabel(item.label, language)} - + {getLabel(item.label, language)} ); })} @@ -490,18 +529,17 @@ export default function UnifiedNavigation() { setMenuOpen(false)} > {item.icon && ( )} - - {getLabel(item.label, language)} - + {getLabel(item.label, language)} ); })} @@ -517,10 +555,11 @@ export default function UnifiedNavigation() { setMenuOpen(false)} > {typeof item.label === "function" @@ -531,7 +570,7 @@ export default function UnifiedNavigation() {
-
+

{isChinese ? "设置" : "Settings"}