91 | {showClear ? (
92 |
93 | {clearText} {title}
94 |
95 | ) : null}
96 | {showViewMore ? (
97 |
{
99 | if (onViewMore) {
100 | onViewMore(e);
101 | }
102 | }}
103 | >
104 | {viewMoreText}
105 |
106 | ) : null}
107 |
108 |
109 | );
110 | };
111 |
112 | export default NoticeList;
113 |
--------------------------------------------------------------------------------
/src/components/NoticeIcon/index.less:
--------------------------------------------------------------------------------
1 | @import '~antd/es/style/themes/default.less';
2 |
3 | .popover {
4 | position: relative;
5 | width: 336px;
6 | }
7 |
8 | .noticeButton {
9 | display: inline-block;
10 | cursor: pointer;
11 | transition: all 0.3s;
12 | }
13 | .icon {
14 | padding: 4px;
15 | vertical-align: middle;
16 | }
17 |
18 | .badge {
19 | font-size: 16px;
20 | }
21 |
22 | .tabs {
23 | :global {
24 | .ant-tabs-nav-list {
25 | margin: auto;
26 | }
27 |
28 | .ant-tabs-nav-scroll {
29 | text-align: center;
30 | }
31 | .ant-tabs-bar {
32 | margin-bottom: 0;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/components/NoticeIcon/index.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState, useCallback } from 'react';
2 | import { Tag, message } from 'antd';
3 | import { groupBy } from 'lodash';
4 | import moment from 'moment';
5 | import { useModel } from 'umi';
6 | import { queryNotices } from '@/services/user';
7 |
8 | import NoticeIcon from './NoticeIcon';
9 | import styles from './index.less';
10 |
11 | const getNoticeData = (
12 | notices: API.NoticeIconData[],
13 | ): {
14 | [key: string]: API.NoticeIconData[];
15 | } => {
16 | if (!notices || notices.length === 0 || !Array.isArray(notices)) {
17 | return {};
18 | }
19 |
20 | const newNotices = notices.map((notice) => {
21 | const newNotice = { ...notice };
22 |
23 | if (newNotice.datetime) {
24 | newNotice.datetime = moment(notice.datetime as string).fromNow();
25 | }
26 |
27 | if (newNotice.id) {
28 | newNotice.key = newNotice.id;
29 | }
30 |
31 | if (newNotice.extra && newNotice.status) {
32 | const color = {
33 | todo: '',
34 | processing: 'blue',
35 | urgent: 'red',
36 | doing: 'gold',
37 | }[newNotice.status];
38 | newNotice.extra = (
39 |