'use client' import { useCallback, useEffect } from 'react' import Link from 'next/link' import { useBoolean } from 'ahooks' import { useSelectedLayoutSegment } from 'next/navigation' import { Bars3Icon } from '@heroicons/react/20/solid' import { useContextSelector } from 'use-context-selector' import HeaderBillingBtn from '../billing/header-billing-btn' import AccountDropdown from './account-dropdown' import AppNav from './app-nav' import DatasetNav from './dataset-nav' import DatabaseNav from './database-nav' import EnvNav from './env-nav' import ExploreNav from './explore-nav' import ToolsNav from './tools-nav' import GithubStar from './github-star' import LicenseNav from './license-env' import { WorkspaceProvider } from '@/context/workspace-context' import AppContext, { useAppContext } from '@/context/app-context' import LogoSite from '@/app/components/base/logo/logo-site' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import { useProviderContext } from '@/context/provider-context' import { useModalContext } from '@/context/modal-context' import { LicenseStatus } from '@/types/feature' 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 { isCurrentWorkspaceEditor, isCurrentWorkspaceDatasetOperator } = useAppContext() const systemFeatures = useContextSelector(AppContext, v => v.systemFeatures) const selectedSegment = useSelectedLayoutSegment() const media = useBreakpoints() const isMobile = media === MediaType.mobile const [isShowNavMenu, { toggle, setFalse: hideNavMenu }] = useBoolean(false) const { enableBilling, plan } = useProviderContext() const { setShowPricingModal, setShowAccountSettingModal } = useModalContext() const isFreePlan = plan.type === 'sandbox' const handlePlanClick = useCallback(() => { if (isFreePlan) setShowPricingModal() else setShowAccountSettingModal({ payload: 'billing' }) }, [isFreePlan, setShowAccountSettingModal, setShowPricingModal]) useEffect(() => { hideNavMenu() // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedSegment]) return ( //首页顶部导航栏nav 云脑
{isMobile &&
} {!isMobile && <> {systemFeatures.license.status === LicenseStatus.NONE && } }
{isMobile && (
{systemFeatures.license.status === LicenseStatus.NONE && }
)} {!isMobile && (
{/* {!isCurrentWorkspaceDatasetOperator && } */} {/* 工作室nav */} {!isCurrentWorkspaceDatasetOperator && } {(isCurrentWorkspaceEditor || isCurrentWorkspaceDatasetOperator) && } {(isCurrentWorkspaceEditor || isCurrentWorkspaceDatasetOperator) && } {/* {!isCurrentWorkspaceDatasetOperator && } */}
)}
{enableBilling && (
)}
{(isMobile && isShowNavMenu) && (
{/* {!isCurrentWorkspaceDatasetOperator && } */} {!isCurrentWorkspaceDatasetOperator && } {(isCurrentWorkspaceEditor || isCurrentWorkspaceDatasetOperator) && } {(isCurrentWorkspaceEditor || isCurrentWorkspaceDatasetOperator) && } {/* {!isCurrentWorkspaceDatasetOperator && } */}
)}
) } export default Header