'use client' import { useEffect, useRef, useState } from 'react' import Link from 'next/link' import { useBoolean, useClickAway } from 'ahooks' import { useSelectedLayoutSegment } from 'next/navigation' import { Bars3Icon } from '@heroicons/react/20/solid' import HeaderBillingBtn from '../billing/header-billing-btn' import AccountDropdown from './account-dropdown' import AppNav from './app-nav' import DatasetNav from './dataset-nav' import EnvNav from './env-nav' import ExploreNav from './explore-nav' import ToolsNav from './tools-nav' import GithubStar from './github-star' import { WorkspaceProvider } from '@/context/workspace-context' import { useAppContext } from '@/context/app-context' import LogoSite from '@/app/components/base/logo/logo-site' import PlanComp from '@/app/components/billing/plan' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import { useProviderContext } from '@/context/provider-context' const navClassName = ` flex items-center relative mr-0 sm:mr-3 px-3 h-8 rounded-xl font-medium text-sm cursor-pointer ` const Header = () => { const { isCurrentWorkspaceManager, langeniusVersionInfo } = useAppContext() const [showUpgradePanel, setShowUpgradePanel] = useState(false) const upgradeBtnRef = useRef(null) useClickAway(() => { setShowUpgradePanel(false) }, upgradeBtnRef) const selectedSegment = useSelectedLayoutSegment() const media = useBreakpoints() const isMobile = media === MediaType.mobile const [isShowNavMenu, { toggle, setFalse: hideNavMenu }] = useBoolean(false) const { enableBilling } = useProviderContext() useEffect(() => { hideNavMenu() // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedSegment]) return (
{isMobile &&
} {!isMobile && <> }
{isMobile && (
)} {!isMobile && (
{isCurrentWorkspaceManager && }
)}
{enableBilling && (
setShowUpgradePanel(true)} /> {showUpgradePanel && (
)}
)}
{(isMobile && isShowNavMenu) && (
{isCurrentWorkspaceManager && }
)}
) } export default Header