| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import Link from "next/link";
- // import { Suspense } from "react";
- import LogoIcon from "@components/common/icons/LogoIcon";
- // import MobileMenuTrigger from "./MobileMenuTrigger";
- import { NavbarActions } from "./NavbarActions";
- // import { NavigationSkeleton } from "./NavigationSkeleton";
- import { NavbarErrorBoundary } from "@/components/error/ErrorBoundary";
- import DesktopNavigation from "./DesktopNavigation";
- import {
- GET_TREEFRONT_MENUS } from "@/graphql";
- import { serverGraphqlFetch } from "@utils/bagisto/index";
- import NavbarSearchIcon from "./NavbarSearchIcon"
- import type { GetTreefrontMenusResult } from "@/types/theme/menus";
- import { authOptions } from "@utils/auth";
- import { getServerSession } from "next-auth";
- import TopSwiperBanner from "./TopSwiperBanner"
- export default async function Navbar() {
- const session = await getServerSession(authOptions);// 游客是null
- const isGuest = session === null;
- const { data: menudata } = await serverGraphqlFetch<
- GetTreefrontMenusResult
- >({
- query: GET_TREEFRONT_MENUS,
- });
- console.log('GetTreefrontMenusResult --- ',menudata)
- const menudatas =menudata? menudata.treefrontMenus:[];
- return (
- <NavbarErrorBoundary>
- <header className="sticky top-0 z-10">
- <TopSwiperBanner />
- <nav className="relative flex flex-col items-center justify-between gap-4 bg-neutral-50 pt-3 pb-3 dark:bg-neutral-900 md:flex-row ">
- <div className="flex w-full items-center justify-between max-w-[1440px] m-auto gap-0 sm:gap-4">
- {/* 1. THE STATIC SHELL (Visible Instantly) */}
- <div className="flex items-center max-w-fit gap-5 xl:gap-6">
- {/* 2. STATIC HOLE: Categories (Suspended) */}
- {/* <Suspense fallback={<NavigationSkeleton />}>
- <MobileMenuTrigger isGuest={isGuest} menuData={menudatas} />
- </Suspense> */}
- <div className="flex-1 justify-center flex">
- {/* <Suspense fallback={<SearchSkeleton />}>
- <Search search={false} />
- </Suspense> */}
- <NavbarSearchIcon/>
- </div>
- </div>
- <Link
- className="flex-initial h-9 w-36.5"
- href="/"
- aria-label="Go to homepage"
- >
- <LogoIcon />
- </Link>
-
- <NavbarActions isGuest={isGuest} />
-
- </div>
- </nav>
- <DesktopNavigation menus={menudatas}/>
- </header>
- </NavbarErrorBoundary>
- );
- }
|