text: 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';
  
  const url = window.location.href
  const realCache = url.includes('enterprise') ? JSON.parse(localStorage.getItem('enterpriseCache'))
    : url.includes('admin') ? JSON.parse(localStorage.getItem('adminCache'))
      : [];
  
  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 = (
            <Tag color={color} style={{ marginRight: 0 }}>
              {newNotice.extra}
            </Tag>
          );
        }
        return newNotice;
      });
      return groupBy(newNotices, 'type');
    }
  
    render() {
      const {
        onMenuClick,
        theme,
      } = this.props;
      const menu = (
        <Menu className={styles.menu} selectedKeys={[]} onClick={onMenuClick}>
          <Menu.Item key="logout">
            <Icon type="logout" />
            <FormattedMessage id="menu.account.logout" defaultMessage="logout" />
          </Menu.Item>
        </Menu>
      );
      let className = styles.right;
      if (theme === 'dark') {
        className = `${styles.right}  ${styles.dark}`;
      }
      return (
        <div className={className}>
          {realCache && realCache.userName ? (
            <Dropdown overlay={menu}>
              <span className={`${styles.action} ${styles.account}`}>
                <Avatar
                  size="small"
                  className={styles.avatar}
                  src={realCache.avatar}
                  alt="avatar"
                />
                <span className={styles.name}>
                  {
                    realCache.companyName ? `${realCache.companyName}-${realCache.userName}` : realCache.userName
                  }
                </span>
              </span>
            </Dropdown>
          )
            : (
              <Spin size="small" style={{ marginLeft: 8, marginRight: 8 }} />
            )}
          {/* <SelectLang className={styles.action} /> */}
        </div>
      );
    }
  }
  