|
|
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
|
|
|
import { Tag, message } from 'antd';
|
|
|
import { groupBy } from 'lodash';
|
|
|
import moment from 'moment';
|
|
|
-import { useModel } from 'umi';
|
|
|
+import { useModel, useRequest } from 'umi';
|
|
|
import { getNotices } from '@/services/ant-design-pro/api';
|
|
|
|
|
|
import NoticeIcon from './NoticeIcon';
|
|
|
@@ -74,10 +74,11 @@ const NoticeIconView = () => {
|
|
|
const { initialState } = useModel('@@initialState');
|
|
|
const { currentUser } = initialState || {};
|
|
|
const [notices, setNotices] = useState<API.NoticeIconItem[]>([]);
|
|
|
+ const { data } = useRequest(getNotices());
|
|
|
|
|
|
useEffect(() => {
|
|
|
- getNotices().then(({ data }) => setNotices(data || []));
|
|
|
- }, []);
|
|
|
+ setNotices(data || []);
|
|
|
+ }, [data]);
|
|
|
|
|
|
const noticeData = getNoticeData(notices);
|
|
|
const unreadMsg = getUnreadData(noticeData || {});
|