1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React, { useEffect } from 'react';
import { useModel, history, useRequest } from 'umi';
import { Badge } from 'antd';
import utilsStyles from '@/utils/utils.less';
import { fetchMessageInfo } from "@/services/dict";
const Index: React.FC = () => {
const { initialState } = useModel('@@initialState');
const fetchMessageResquest = useRequest(fetchMessageInfo,{
pollingInterval:5000,
pollingWhenHidden: false,
manual:true,
});
useEffect(()=>{
const userId = initialState?.currentUser?.id;
if (userId) {
fetchMessageResquest.run(userId)
}
return () =>{
fetchMessageResquest.cancel();
};
},[initialState?.currentUser?.id]);
return (
<a className="pos_center" onClick={() => history.push(`/information/manage`)}>
<div style={{ lineHeight: 1, display: 'inline-block',margin:'0 12px 0 4px'}}>
<Badge count={fetchMessageResquest?.data?.unRead || 0} overflowCount={99} style={{ marginRight: -8 }}>
{/* <BellFilled style={{ color: '#fff', fontSize: 24, }} /> */}
<img src='/img/mes.png' className = { utilsStyles.topIcon } />
</Badge>
</div>
</a>
);
};
export default Index;