From 3c1f5ec27d55ce643f66c7d099486f4fb19841b0 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Mon, 16 Mar 2026 21:08:38 +0800 Subject: [PATCH] Refine mobile navigation experience --- src/components/UnifiedNavigation.tsx | 268 ++++++++++++++------------- 1 file changed, 136 insertions(+), 132 deletions(-) diff --git a/src/components/UnifiedNavigation.tsx b/src/components/UnifiedNavigation.tsx index f281d70..510273c 100644 --- a/src/components/UnifiedNavigation.tsx +++ b/src/components/UnifiedNavigation.tsx @@ -4,7 +4,7 @@ import Image from "next/image"; import { usePathname } from "next/navigation"; import { useEffect, useRef, useState } from "react"; import { useLanguage } from "../i18n/LanguageProvider"; -import { Menu, X, Sun, Moon, Monitor, Plus, BarChart2 } from "lucide-react"; +import { Menu, X } from "lucide-react"; import { translations } from "../i18n/translations"; import LanguageToggle from "./LanguageToggle"; // import { AskAIButton } from "./AskAIButton"; @@ -32,7 +32,6 @@ const getLabel = ( export default function UnifiedNavigation() { const pathname = usePathname(); const [menuOpen, setMenuOpen] = useState(false); - const [useMobileDrawer, setUseMobileDrawer] = useState(false); const [selectedChannels, setSelectedChannels] = useState([ "stable", ]); @@ -130,20 +129,6 @@ export default function UnifiedNavigation() { }; }, [menuOpen]); - useEffect(() => { - if (typeof window === "undefined") { - return; - } - - const userAgent = window.navigator.userAgent || ""; - const platform = window.navigator.platform || ""; - const touchPoints = window.navigator.maxTouchPoints || 0; - const mobileOS = - /Android|iPhone|iPad|iPod/i.test(userAgent) || - (platform === "MacIntel" && touchPoints > 1); - setUseMobileDrawer(mobileOS); - }, []); - useEffect(() => { if (typeof window === "undefined") { return; @@ -195,6 +180,12 @@ export default function UnifiedNavigation() { const filteredMainNav = filterNavItems(mainNav, user); const filteredSecondaryNav = filterNavItems(secondaryNav, user); + const mobilePrimaryNav = [...filteredMainNav, ...filteredSecondaryNav].filter( + (item) => item.showOn !== "desktop", + ); + const mobileQuickLinks = mobilePrimaryNav.filter((item) => + ["chat", "console", "docs", "services"].includes(item.key), + ); const isHiddenRoute = pathname ? [ @@ -433,18 +424,12 @@ export default function UnifiedNavigation() { {menuOpen && (
setMenuOpen(false)} /> -
-
-
+
+
+
- + Cloud-Neutral - +
+
+ +
+ +
- {user && ( -
-
-
+
+ {user ? ( +
+
{accountInitial}
-
-

+

+

{user.username}

@@ -486,17 +476,11 @@ export default function UnifiedNavigation() {

-
- )} + ) : null} -
-

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

-
- {filteredMainNav.map((item) => { +
+ {mobilePrimaryNav.map((item) => { const active = isActive(item); - if (item.showOn === "desktop") return null; if (item.key === "chat") { return ( ); } @@ -522,95 +514,107 @@ export default function UnifiedNavigation() { setMenuOpen(false)} > - {item.icon && ( - - )} - {getLabel(item.label, language)} + + {getLabel(item.label, language)} + + + {isChinese ? "查看" : "View"} + ); })}
- {filteredSecondaryNav.length > 0 && ( - <> -

- {isChinese ? "其他" : "Other"} -

-
- {filteredSecondaryNav.map((item) => { - const active = isActive(item); - if (item.showOn === "desktop") return null; - return ( - setMenuOpen(false)} - > - {item.icon && ( - - )} - {getLabel(item.label, language)} - - ); - })} + {mobileQuickLinks.length > 0 ? ( +
+
+

+ {isChinese ? "快捷入口" : "Shortcuts"} +

+
+ {mobileQuickLinks.map((item) => + item.key === "chat" ? ( + + ) : ( + setMenuOpen(false)} + className="block text-[1.05rem] font-medium tracking-[-0.03em] text-text transition hover:text-primary" + > + {getLabel(item.label, language)} + + ), + )} +
- - )} - -
-

- {isChinese ? "账户" : "Account"} -

- {accountNav.map((item) => ( - setMenuOpen(false)} - > - {typeof item.label === "function" - ? item.label(language) - : item.label} - - ))} -
+
+ ) : null}
-
-
-

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

-
- - {isChinese ? "界面语言" : "Language"} - - +
+
+
+
+ +
+
+ + {accountInitial} + + + {user + ? user.username || user.email + : isChinese + ? "访客模式" + : "Guest mode"} + +
-
- - {isChinese ? "发布频道" : "Channels"} - - + +
+ {accountNav.map((item) => ( + setMenuOpen(false)} + > + {typeof item.label === "function" + ? item.label(language) + : item.label} + + ))}