|
|
@@ -1,7 +1,8 @@
|
|
|
-import React, { PureComponent } from 'react';
|
|
|
+import React, { PureComponent, Fragment } from 'react';
|
|
|
import ReactDOM from 'react-dom';
|
|
|
-import { Popover, Icon, Tabs, Badge, Spin } from 'antd';
|
|
|
+import { Icon, Tabs, Badge, Spin } from 'antd';
|
|
|
import classNames from 'classnames';
|
|
|
+import HeaderDropdown from '../HeaderDropdown';
|
|
|
import List from './NoticeList';
|
|
|
import styles from './index.less';
|
|
|
|
|
|
@@ -24,6 +25,10 @@ export default class NoticeIcon extends PureComponent {
|
|
|
emptyImage: 'https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg',
|
|
|
};
|
|
|
|
|
|
+ state = {
|
|
|
+ visible: false,
|
|
|
+ };
|
|
|
+
|
|
|
onItemClick = (item, tabProps) => {
|
|
|
const { onItemClick } = this.props;
|
|
|
const { clickClose } = item;
|
|
|
@@ -70,21 +75,30 @@ export default class NoticeIcon extends PureComponent {
|
|
|
);
|
|
|
});
|
|
|
return (
|
|
|
- <Spin spinning={loading} delay={0}>
|
|
|
- <Tabs className={styles.tabs} onChange={this.onTabChange}>
|
|
|
- {panes}
|
|
|
- </Tabs>
|
|
|
- </Spin>
|
|
|
+ <Fragment>
|
|
|
+ <Spin spinning={loading} delay={0}>
|
|
|
+ <Tabs className={styles.tabs} onChange={this.onTabChange}>
|
|
|
+ {panes}
|
|
|
+ </Tabs>
|
|
|
+ </Spin>
|
|
|
+ </Fragment>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ handleVisibleChange = visible => {
|
|
|
+ const { onPopupVisibleChange } = this.props;
|
|
|
+ this.setState({ visible });
|
|
|
+ onPopupVisibleChange(visible);
|
|
|
+ };
|
|
|
+
|
|
|
render() {
|
|
|
- const { className, count, popupAlign, popupVisible, onPopupVisibleChange, bell } = this.props;
|
|
|
+ const { className, count, popupVisible, bell } = this.props;
|
|
|
+ const { visible } = this.state;
|
|
|
const noticeButtonClass = classNames(className, styles.noticeButton);
|
|
|
const notificationBox = this.getNotificationBox();
|
|
|
const NoticeBellIcon = bell || <Icon type="bell" className={styles.icon} />;
|
|
|
const trigger = (
|
|
|
- <span className={noticeButtonClass}>
|
|
|
+ <span className={classNames(noticeButtonClass, { opened: visible })}>
|
|
|
<Badge count={count} style={{ boxShadow: 'none' }} className={styles.badge}>
|
|
|
{NoticeBellIcon}
|
|
|
</Badge>
|
|
|
@@ -98,19 +112,18 @@ export default class NoticeIcon extends PureComponent {
|
|
|
popoverProps.visible = popupVisible;
|
|
|
}
|
|
|
return (
|
|
|
- <Popover
|
|
|
+ <HeaderDropdown
|
|
|
placement="bottomRight"
|
|
|
- content={notificationBox}
|
|
|
- popupClassName={styles.popover}
|
|
|
- trigger="click"
|
|
|
- arrowPointAtCenter
|
|
|
- popupAlign={popupAlign}
|
|
|
- onVisibleChange={onPopupVisibleChange}
|
|
|
+ overlay={notificationBox}
|
|
|
+ overlayClassName={styles.popover}
|
|
|
+ trigger={['click']}
|
|
|
+ visible={visible}
|
|
|
+ onVisibleChange={this.handleVisibleChange}
|
|
|
{...popoverProps}
|
|
|
ref={node => (this.popover = ReactDOM.findDOMNode(node))} // eslint-disable-line
|
|
|
>
|
|
|
{trigger}
|
|
|
- </Popover>
|
|
|
+ </HeaderDropdown>
|
|
|
);
|
|
|
}
|
|
|
}
|