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/storeChat'; import { HUMAN_ICON } from '@fastgpt/global/common/system/constants'; import { feConfigs } from '@/web/common/system/staticData'; import NextLink from 'next/link'; import Badge from '../Badge'; import Avatar from '../Avatar'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { useTranslation } from 'next-i18next'; import { useSystemStore } from '@/web/common/system/useSystemStore'; import MyTooltip from '../MyTooltip'; import { getDocPath } from '@/web/common/system/doc'; export enum NavbarTypeEnum { normal = 'normal', small = 'small' } const Navbar = ({ unread }: { unread: number }) => { const { t } = useTranslation(); const router = useRouter(); const { userInfo } = useUserStore(); const { gitStar } = useSystemStore(); const { lastChatAppId, lastChatId } = useChatStore(); const navbarList = useMemo( () => [ { label: t('navbar.Chat'), icon: 'core/chat/chatLight', activeIcon: 'chatcore/dataset/chatFillFill', link: `/chat?appId=${lastChatAppId}&chatId=${lastChatId}`, activeLink: ['/chat'] }, { label: t('navbar.Apps'), icon: 'core/app/aiLight', activeIcon: 'core/app/aiFill', link: `/app/list`, activeLink: ['/app/list', '/app/detail'] }, { label: t('navbar.Plugin'), icon: 'common/navbar/pluginLight', activeIcon: 'common/navbar/pluginFill', link: `/plugin/list`, activeLink: ['/plugin/list', '/plugin/edit'] }, { label: t('navbar.Datasets'), icon: 'core/dataset/datasetLight', activeIcon: 'core/dataset/datasetFill', link: `/dataset/list`, activeLink: ['/dataset/list', '/dataset/detail'] }, { label: t('navbar.Account'), icon: 'support/user/userLight', activeIcon: 'support/user/userFill', link: '/account', activeLink: ['/account'] } ], [lastChatAppId, lastChatId, t] ); const itemStyles: BoxProps & LinkProps = { my: 3, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', cursor: 'pointer', w: '48px', h: '58px', borderRadius: 'md' }; return ( {/* logo */} router.push('/account')} > {/* 导航列表 */} {navbarList.map((item) => ( router.push(item.link) } : {})} > {item.label} ))} {unread > 0 && ( )} {(feConfigs?.docUrl || feConfigs?.chatbotUrl) && ( )} {feConfigs?.show_git && ( )} ); }; export default Navbar;