import React, { PureComponent } from 'react'; import { FormattedMessage, formatMessage } from 'umi/locale'; import { Spin, Tag, Menu, Icon, Dropdown, Avatar, Tooltip } from 'antd'; import moment from 'moment'; import groupBy from 'lodash/groupBy'; import NoticeIcon from '../NoticeIcon'; import HeaderSearch from '../HeaderSearch'; import SelectLang from '../SelectLang'; import styles from './index.less'; export default class GlobalHeaderRight extends PureComponent { getNoticeData() { const { notices = [] } = this.props; if (notices.length === 0) { return {}; } const newNotices = notices.map(notice => { const newNotice = { ...notice }; if (newNotice.datetime) { newNotice.datetime = moment(notice.datetime).fromNow(); } if (newNotice.id) { newNotice.key = newNotice.id; } if (newNotice.extra && newNotice.status) { const color = { todo: '', processing: 'blue', urgent: 'red', doing: 'gold', }[newNotice.status]; newNotice.extra = ( {newNotice.extra} ); } return newNotice; }); return groupBy(newNotices, 'type'); } render() { const { currentUser, fetchingNotices, onNoticeVisibleChange, onMenuClick, onNoticeClear, theme, } = this.props; const menu = ( ); const noticeData = this.getNoticeData(); let className = styles.right; if (theme === 'dark') { className = `${styles.right} ${styles.dark}`; } return (
{ console.log('input', value); // eslint-disable-line }} onPressEnter={value => { console.log('enter', value); // eslint-disable-line }} /> { console.log(item, tabProps); // eslint-disable-line }} onClear={onNoticeClear} onPopupVisibleChange={onNoticeVisibleChange} loading={fetchingNotices} popupAlign={{ offset: [20, -16] }} > {currentUser.name ? ( {currentUser.name} ) : ( )}
); } }