增加AI页面在其它页面的展示

This commit is contained in:
allen2fuc
2026-05-08 18:15:52 +08:00
parent 9817ecca33
commit 68f06344dc
9 changed files with 334 additions and 15 deletions
+47 -6
View File
@@ -6,6 +6,8 @@
- Inactive: muted icon + label
============================================================ */
import { cn } from "@/lib/utils";
import { useAIDrawer } from "@/contexts/AIDrawerContext";
import { useIsLgUp } from "@/hooks/useIsLgUp";
import {
Activity,
Bot,
@@ -31,6 +33,8 @@ const NAV_ITEMS: NavItem[] = [
export default function BottomNav() {
const [location] = useLocation();
const isLgUp = useIsLgUp();
const { open: aiDrawerOpen, setOpen: setAiDrawerOpen } = useAIDrawer();
return (
<nav
@@ -46,14 +50,16 @@ export default function BottomNav() {
>
<div className="flex items-stretch justify-around">
{NAV_ITEMS.map((item) => {
const isActive = location === item.path ||
(item.path === "/" && location === "/") ||
(item.path !== "/" && location.startsWith(item.path));
const isActive =
item.path === "/ai"
? location === "/ai" || (isLgUp && aiDrawerOpen)
: location === item.path ||
(item.path === "/" && location === "/") ||
(item.path !== "/" && location.startsWith(item.path));
const Icon = item.icon;
return (
<Link key={item.path} href={item.path}>
<div className="flex flex-col items-center justify-center relative pt-2.5 pb-1.5 px-3">
const inner = (
<div className="flex flex-col items-center justify-center relative pt-2.5 pb-1.5 px-3">
{/* Active indicator bar */}
<div
className="absolute top-0 left-1/2 -translate-x-1/2 rounded-b-full transition-all duration-300"
@@ -99,6 +105,41 @@ export default function BottomNav() {
{item.label}
</span>
</div>
);
if (item.path === "/ai") {
if (!isLgUp) {
return (
<Link key={item.path} href={item.path}>
{inner}
</Link>
);
}
return (
<div
key={item.path}
role="button"
tabIndex={0}
className="cursor-pointer select-none"
onClick={() => {
if (location === "/ai") return;
setAiDrawerOpen((o) => !o);
}}
onKeyDown={(e) => {
if (e.key !== "Enter" && e.key !== " ") return;
e.preventDefault();
if (location === "/ai") return;
setAiDrawerOpen((o) => !o);
}}
>
{inner}
</div>
);
}
return (
<Link key={item.path} href={item.path}>
{inner}
</Link>
);
})}