import * as React from 'react'; import classNames from 'classnames'; import { FormattedMessage } from 'react-intl'; import { Link } from 'bisheng/router'; import { UnorderedListOutlined } from '@ant-design/icons'; import { Menu } from 'antd'; import { getEcosystemGroup } from './More'; import * as utils from '../../utils'; import { SharedProps } from './interface'; import './Navigation.less'; export interface NavigationProps extends SharedProps { isMobile: boolean; isRTL: boolean; pathname: string; responsive: null | 'narrow' | 'crowded'; location: { pathname: string }; directionText: string; onLangChange: () => void; onDirectionChange: () => void; } export default ({ isZhCN, isRTL, isMobile, pathname, responsive, location, directionText, onLangChange, onDirectionChange, }: NavigationProps) => { const [isGitee, setIsGitee] = React.useState(false); const menuMode = isMobile ? 'inline' : 'horizontal'; const module = pathname.split('/').slice(0, -1).join('/'); let activeMenuItem = module || 'home'; if (location.pathname === 'changelog' || location.pathname === 'changelog-cn') { activeMenuItem = 'docs/react'; } else if (location.pathname === 'docs/resources' || location.pathname === 'docs/resources-cn') { activeMenuItem = 'docs/resources'; } let additional: React.ReactNode = null; const additionalItems = [ Github , , {directionText} , getEcosystemGroup({ isZhCN, isRTL }), ]; if (isMobile) { additional = additionalItems; } else if (responsive === 'crowded') { additional = ( }> {additionalItems} ); } React.useEffect(() => { setIsGitee(document.location.host.indexOf('gitee') !== -1); }, []); return ( {isZhCN && !isGitee && ( 国内镜像 )} {additional} ); };