import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Button } from '@/components/ui/button'; import { Container } from '@/components/ui/container'; import { Segmented, SegmentedValue } from '@/components/ui/segmented'; import { useTranslate } from '@/hooks/common-hooks'; import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks'; import { useNavigateWithFromState } from '@/hooks/route-hook'; import { cn } from '@/lib/utils'; import { Routes } from '@/routes'; import { ChevronDown, Cpu, File, Github, House, Library, MessageSquareText, Search, Star, Zap, } from 'lucide-react'; import { useCallback, useMemo } from 'react'; import { useLocation } from 'umi'; export function Header() { const { t } = useTranslate('header'); const { pathname } = useLocation(); const navigate = useNavigateWithFromState(); const { navigateToHome, navigateToProfile } = useNavigatePage(); const tagsData = useMemo( () => [ { path: Routes.Datasets, name: t('knowledgeBase'), icon: Library }, { path: Routes.Chat, name: t('chat'), icon: MessageSquareText }, { path: Routes.Search, name: t('search'), icon: Search }, { path: Routes.Agent, name: t('flow'), icon: Cpu }, { path: Routes.Files, name: t('fileManager'), icon: File }, ], [t], ); const options = useMemo(() => { return tagsData.map((tag) => { const HeaderIcon = tag.icon; return { label: (
{tag.name}
), value: tag.path, }; }); }, [tagsData]); const currentPath = useMemo(() => { return ( tagsData.find((x) => pathname.startsWith(x.path))?.path || Routes.Home ); }, [pathname, tagsData]); const isHome = Routes.Home === currentPath; const handleChange = (path: SegmentedValue) => { navigate(path as Routes); }; const handleLogoClick = useCallback(() => { navigate(Routes.Home); }, [navigate]); return (
logo
V 0.13.0 CN yifanwu92@gmail.com
); }