import * as React from 'react'; import './index.less'; import { userLogOut } from 'lib/api'; import { notification, Dropdown, Icon, Tooltip, Popover } from 'component/antd'; import { urlPrefix } from 'constants/left-menu'; import { region, IRegionIdcs } from 'store/region'; import logoUrl from '../../assets/image/kafka-logo.png'; import userIcon from '../../assets/image/normal.png'; import weChat from '../../assets/image/wechat.jpeg'; import { users } from 'store/users'; import { observer } from 'mobx-react'; import { Link } from 'react-router-dom'; import './index.less'; interface IHeader { active: string; } interface IMenuItem { active: boolean; label: string; href: string; show: boolean; } export const Header = observer((props: IHeader) => { const { active } = props; const role = users.currentUser.role; const headerMenu = [{ active: active === 'topic', label: 'Topic管理', href: `/topic`, show: true, }, { active: active === 'cluster', label: '集群管理', href: `/cluster`, show: true, }, { active: active === 'alarm', label: '监控告警', href: `/alarm`, show: true, }, { active: active === 'admin', label: '运维管控', href: `/admin`, show: role !== 0, }, { active: active === 'expert', label: '专家服务', href: `/expert`, show: role === 2, }]; const logOut = () => { userLogOut().then(() => { notification.success({ message: '退出成功' }); }); }; const content = (
); const helpCenter = ( ); const menu = ( ); const handleChangeRegion = (value: IRegionIdcs) => { region.changeRegion(value); location.assign(handleJumpLocation()); }; const handleJumpLocation = (): string => { const isDetailPage = window.location.pathname.includes('detail'); const pathNames = window.location.pathname.split('/'); const loc = window.location.pathname.includes('error') ? `${urlPrefix}/topic` : window.location.pathname; return isDetailPage ? pathNames.splice(0, 3).join('/') : loc; }; const regionMenu = ( ); const isLongName = (users.currentUser.chineseName ? users.currentUser.chineseName.length > 8 : users.currentUser.username ? users.currentUser.username.length > 11 : false); return (
Kafka Manager v2.4.0 {/* 添加版本超链接 */}
{headerMenu.map((item: IMenuItem, index: number) => item.show ? {item.label} : null, )}
帮助中心 {region.regionName} {isLongName ? {users.currentUser.chineseName || users.currentUser.username} : {users.currentUser.chineseName || users.currentUser.username} }
); });