import React, { useMemo } from 'react'; import { Box, BoxProps, Flex, Link, LinkProps } from '@chakra-ui/react'; import { useRouter } from 'next/router'; import { useUserStore } from '@/web/support/user/useUserStore'; import { useChatStore } from '@/web/core/chat/context/useChatStore'; import { HUMAN_ICON } from '@fastgpt/global/common/system/constants'; import NextLink from 'next/link'; import Badge from '../Badge'; import Avatar from '@fastgpt/web/components/common/Avatar'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { useTranslation } from 'next-i18next'; import { useSystemStore } from '@/web/common/system/useSystemStore'; import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; export enum NavbarTypeEnum { normal = 'normal', small = 'small' } const itemStyles: BoxProps & LinkProps = { my: 2, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', cursor: 'pointer', w: '48px', h: '58px', borderRadius: 'md' }; const hoverStyle: LinkProps = { _hover: { bg: 'myGray.05', color: 'primary.600' } }; const Navbar = ({ unread }: { unread: number }) => { const { t } = useTranslation(); const router = useRouter(); const { userInfo } = useUserStore(); const { gitStar, feConfigs } = useSystemStore(); const { lastChatAppId } = useChatStore(); const navbarList = useMemo( () => [ { label: t('common:navbar.Chat'), icon: 'core/chat/chatLight', activeIcon: 'core/chat/chatFill', link: `/chat?appId=${lastChatAppId}`, activeLink: ['/chat'] }, { label: t('common:navbar.Studio'), icon: 'core/app/aiLight', activeIcon: 'core/app/aiFill', link: `/dashboard/apps`, activeLink: [ '/dashboard/apps', '/app/detail', '/dashboard/templateMarket', '/dashboard/[pluginGroupId]', '/dashboard/mcpServer' ] }, { label: t('common:navbar.Datasets'), icon: 'core/dataset/datasetLight', activeIcon: 'core/dataset/datasetFill', link: `/dataset/list`, activeLink: ['/dataset/list', '/dataset/detail'] }, { label: t('common:navbar.Account'), icon: 'support/user/userLight', activeIcon: 'support/user/userFill', link: '/account/info', activeLink: [ '/account/bill', '/account/info', '/account/team', '/account/usage', '/account/thirdParty', '/account/apikey', '/account/setting', '/account/inform', '/account/promotion', '/account/model' ] } ], [lastChatAppId, t] ); const isSecondNavbarPage = useMemo(() => { return ['/toolkit'].includes(router.pathname); }, [router.pathname]); return ( {/* logo */} router.push('/account/info')} > {/* 导航列表 */} {navbarList.map((item) => { const isActive = item.activeLink.includes(router.pathname); return ( router.push(item.link) } : {})} > {item.label} ); })} {unread > 0 && ( )} {feConfigs?.navbarItems ?.filter((item) => item.isActive) .map((item) => ( ))} {feConfigs?.show_git && ( )} ); }; export default Navbar;