Commit a2f2fee8 authored by 叶飞's avatar 叶飞

feat: notice

parent 02566d61
...@@ -34,80 +34,19 @@ class NoticeIconView extends Component { ...@@ -34,80 +34,19 @@ class NoticeIconView extends Component {
}) })
}; };
/* eslint-disable no-unused-vars */
changeReadState = clickedItem => {};
/* eslint-disable no-unused-vars */
handleNoticeClear = (title, key) => {};
getNoticeData = () => {
const { notices = [] } = this.props;
if (!notices || notices.length === 0 || !Array.isArray(notices)) {
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;
});
};
render() { render() {
const { currentUser, fetchingNotices, onNoticeVisibleChange } = this.props;
const noticeData = [];
//this.getNoticeData();
const unreadMsg = [];
//this.getUnreadData(noticeData);
return ( return (
<NoticeIcon <NoticeIcon
className={styles.action} className={styles.action}
count={this.state.count} count={this.state.count}
onItemClick={item => { confirmRead={this.notifier.confirmRead}
this.changeReadState(item);
}}
loading={fetchingNotices}
confirmRead={this.notifier.confirmRead.bind(this.notifier)}
onClear={this.handleNoticeClear}
onPopupVisibleChange={onNoticeVisibleChange}
onViewMore={() => message.info('Click on view more')}
clearClose
> >
<NoticeIcon.Tab <NoticeIcon.Tab
tabKey="notification"
list={this.state.noticeData} list={this.state.noticeData}
title="通知" title="通知"
emptyText="你已查看所有通知" emptyText="你已查看所有通知"
showViewMore confirmRead={this.notifier.confirmRead}
confirmRead={this.notifier.confirmRead.bind(this.notifier)}
/> />
</NoticeIcon> </NoticeIcon>
); );
......
...@@ -140,7 +140,7 @@ const GlobalHeaderRight = props => { ...@@ -140,7 +140,7 @@ const GlobalHeaderRight = props => {
<HomeIcon onClick={goHome}/> <HomeIcon onClick={goHome}/>
<OrderIcon onClick={handleOrder}/> <OrderIcon onClick={handleOrder}/>
</div> </div>
<NoticeIconView notices={[]} /> <NoticeIconView />
<Avatar menu global={props.global}/> <Avatar menu global={props.global}/>
{/* <SelectLang className={styles.action} /> */} {/* <SelectLang className={styles.action} /> */}
</div> </div>
......
...@@ -18,12 +18,12 @@ const Empty = ({ emptyText }) => ( ...@@ -18,12 +18,12 @@ const Empty = ({ emptyText }) => (
</div> </div>
); );
const NoticeList = ({ data = [], onGoToWidget, emptyText, confirmRead }) => { const NoticeList = ({ data = [], emptyText, confirmRead }) => {
if (!data || data.length === 0) { if (!data || data.length === 0) {
return <Empty emptyText={emptyText} />; return <Empty emptyText={emptyText} />;
} }
return ( return (
<div> <div className={styles.container}>
<List <List
className={styles.list} className={styles.list}
dataSource={data} dataSource={data}
......
@import '~antd/es/style/themes/default.less'; @import '~antd/es/style/themes/default.less';
.list { .container {
max-height: 400px; max-height: 400px;
overflow: auto; overflow: auto;
&::-webkit-scrollbar { &::-webkit-scrollbar {
display: none; display: none;
} }
.list {
.item { .item {
overflow: hidden; overflow: hidden;
cursor: pointer; cursor: pointer;
...@@ -18,43 +19,26 @@ ...@@ -18,43 +19,26 @@
&:last-child { &:last-child {
border-bottom: 0; border-bottom: 0;
} }
} }
} }
.notFound { .notFound {
padding: 73px 0 88px; padding: 73px 0 88px;
color: @text-color-secondary; color: @text-color-secondary;
text-align: center; text-align: center;
border-radius: 0!important; border-radius: 0 !important;
img { img {
display: inline-block; display: inline-block;
height: 76px; height: 76px;
margin-bottom: 16px; margin-bottom: 16px;
} }
} }
.bottomBar { .bottomBar {
height: 46px; height: 46px;
color: @text-color; color: @text-color;
line-height: 46px; line-height: 46px;
text-align: center; text-align: center;
border-top: 1px solid @border-color-split;
border-radius: 0 0 @border-radius-base @border-radius-base;
transition: all 0.3s; transition: all 0.3s;
div {
display: inline-block;
width: 50%;
cursor: pointer;
transition: all 0.3s;
user-select: none;
&:only-child {
width: 100%;
}
&:not(:only-child):last-child {
border-left: 1px solid @border-color-split;
}
} }
} }
...@@ -10,9 +10,8 @@ import Icon from '@ant-design/icons'; ...@@ -10,9 +10,8 @@ import Icon from '@ant-design/icons';
import HeaderDropdown from '../HeaderDropdown'; import HeaderDropdown from '../HeaderDropdown';
import styles from './index.less'; import styles from './index.less';
import NoticeList from './NoticeList'; import NoticeList from './NoticeList';
import http from '../../api';
const { TabPane } = Tabs;
const messageSvg = () => ( const messageSvg = () => (
<svg <svg
version="1.1" version="1.1"
...@@ -48,12 +47,7 @@ const NoticeIcon = props => { ...@@ -48,12 +47,7 @@ const NoticeIcon = props => {
const getNotificationBox = () => { const getNotificationBox = () => {
const { const {
children, children,
loading,
confirmRead, confirmRead,
onClear,
onTabChange,
onItemClick,
onViewMore,
} = props; } = props;
if (!children) { if (!children) {
return null; return null;
...@@ -67,24 +61,12 @@ const NoticeIcon = props => { ...@@ -67,24 +61,12 @@ const NoticeIcon = props => {
const { const {
list, list,
title, title,
count,
tabKey,
showClear,
showViewMore,
} = child.props; } = child.props;
const len = list && list.length ? list.length : 0;
const msgCount = count || count === 0 ? count : len;
const tabTitle = msgCount > 0 ? `${title} (${msgCount})` : title;
panes.push( panes.push(
<NoticeList <NoticeList
{...child.props} {...child.props}
data={list} data={list}
key={child} key={child}
onClear={() => onClear && onClear(title, tabKey)}
onClick={item => onItemClick && onItemClick(item, child.props)}
onViewMore={event => onViewMore && onViewMore(child.props, event)}
showClear={showClear}
showViewMore={showViewMore}
title={title} title={title}
/>, />,
); );
...@@ -100,7 +82,7 @@ const NoticeIcon = props => { ...@@ -100,7 +82,7 @@ const NoticeIcon = props => {
); );
}; };
const { className, count, bell } = props; const { className, bell } = props;
const [visible, setVisible] = useMergeValue(false, { const [visible, setVisible] = useMergeValue(false, {
value: props.popupVisible, value: props.popupVisible,
......
...@@ -53,6 +53,13 @@ class Notifier { ...@@ -53,6 +53,13 @@ class Notifier {
this.MQTTClient = null; this.MQTTClient = null;
this.MQTTOptions = {}; this.MQTTOptions = {};
this.IsNeedReconnect = true; this.IsNeedReconnect = true;
// 对外接口处理this指向问题
this.start=this.start.bind(this);
this.stop=this.stop.bind(this);
this.subscribe=this.subscribe.bind(this);
this.unsubscribe=this.unsubscribe.bind(this);
this.confirmRead=this.confirmRead.bind(this);
} }
// 对外接口 // 对外接口
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment