|
|
@@ -1,6 +1,7 @@
|
|
|
-import React, { PureComponent } from 'react';
|
|
|
-import { FormattedMessage, formatMessage } from 'umi/locale';
|
|
|
+import React, { Component } from 'react';
|
|
|
+import { FormattedMessage, formatMessage } from 'umi-plugin-locale';
|
|
|
import { Spin, Tag, Menu, Icon, Avatar, Tooltip, message } from 'antd';
|
|
|
+import { ClickParam } from 'antd/es/menu';
|
|
|
import moment from 'moment';
|
|
|
import groupBy from 'lodash/groupBy';
|
|
|
import { NoticeIcon } from 'ant-design-pro';
|
|
|
@@ -9,7 +10,29 @@ import HeaderDropdown from '../HeaderDropdown';
|
|
|
import SelectLang from '../SelectLang';
|
|
|
import styles from './index.less';
|
|
|
|
|
|
-export default class GlobalHeaderRight extends PureComponent {
|
|
|
+export declare type SiderTheme = 'light' | 'dark';
|
|
|
+
|
|
|
+interface GlobalHeaderRightProps {
|
|
|
+ notices?: any[];
|
|
|
+ dispatch?: (args: any) => void;
|
|
|
+ // wait for https://github.com/umijs/umi/pull/2036
|
|
|
+ currentUser?: {
|
|
|
+ avatar?: string;
|
|
|
+ name?: string;
|
|
|
+ title?: string;
|
|
|
+ group?: string;
|
|
|
+ signature?: string;
|
|
|
+ geographic?: any;
|
|
|
+ tags?: any[];
|
|
|
+ unreadCount: number;
|
|
|
+ };
|
|
|
+ fetchingNotices?: boolean;
|
|
|
+ onNoticeVisibleChange?: (visible: boolean) => void;
|
|
|
+ onMenuClick?: (param: ClickParam) => void;
|
|
|
+ onNoticeClear?: (tabName: string) => void;
|
|
|
+ theme?: SiderTheme;
|
|
|
+}
|
|
|
+export default class GlobalHeaderRight extends Component<GlobalHeaderRightProps> {
|
|
|
getNoticeData() {
|
|
|
const { notices = [] } = this.props;
|
|
|
if (notices.length === 0) {
|
|
|
@@ -41,7 +64,7 @@ export default class GlobalHeaderRight extends PureComponent {
|
|
|
return groupBy(newNotices, 'type');
|
|
|
}
|
|
|
|
|
|
- getUnreadData = noticeData => {
|
|
|
+ getUnreadData: (noticeData: object) => any = noticeData => {
|
|
|
const unreadMsg = {};
|
|
|
Object.entries(noticeData).forEach(([key, value]) => {
|
|
|
if (!unreadMsg[key]) {
|
|
|
@@ -126,25 +149,26 @@ export default class GlobalHeaderRight extends PureComponent {
|
|
|
<Icon type="question-circle-o" />
|
|
|
</a>
|
|
|
</Tooltip>
|
|
|
+
|
|
|
<NoticeIcon
|
|
|
className={styles.action}
|
|
|
count={currentUser.unreadCount}
|
|
|
onItemClick={(item, tabProps) => {
|
|
|
console.log(item, tabProps); // eslint-disable-line
|
|
|
- this.changeReadState(item, tabProps);
|
|
|
+ this.changeReadState(item);
|
|
|
}}
|
|
|
loading={fetchingNotices}
|
|
|
locale={{
|
|
|
emptyText: formatMessage({ id: 'component.noticeIcon.empty' }),
|
|
|
clear: formatMessage({ id: 'component.noticeIcon.clear' }),
|
|
|
- viewMore: formatMessage({ id: 'component.noticeIcon.view-more' }),
|
|
|
+ viewMore: formatMessage({ id: 'component.noticeIcon.view-more' }), // todo:node_modules/ant-design-pro/lib/NoticeIcon/index.d.ts 21 [key: string]: string;
|
|
|
notification: formatMessage({ id: 'component.globalHeader.notification' }),
|
|
|
message: formatMessage({ id: 'component.globalHeader.message' }),
|
|
|
event: formatMessage({ id: 'component.globalHeader.event' }),
|
|
|
}}
|
|
|
onClear={onNoticeClear}
|
|
|
onPopupVisibleChange={onNoticeVisibleChange}
|
|
|
- onViewMore={() => message.info('Click on view more')}
|
|
|
+ onViewMore={() => message.info('Click on view more')} // todo:onViewMore?: (tabProps: INoticeIconProps) => void;
|
|
|
clearClose
|
|
|
>
|
|
|
<NoticeIcon.Tab
|
|
|
@@ -153,7 +177,7 @@ export default class GlobalHeaderRight extends PureComponent {
|
|
|
title="notification"
|
|
|
emptyText={formatMessage({ id: 'component.globalHeader.notification.empty' })}
|
|
|
emptyImage="https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg"
|
|
|
- showViewMore
|
|
|
+ showViewMore // todo:showViewMore?: boolean; skeletonProps?: SkeletonProps;
|
|
|
/>
|
|
|
<NoticeIcon.Tab
|
|
|
count={unreadMsg.message}
|