mirror of https://github.com/openspug/spug
fix issues
parent
902cfbe89f
commit
ea4c16ae21
|
@ -1,6 +1,6 @@
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Menu, List, Dropdown, Badge, Button, notification } from 'antd';
|
import { Menu, List, Dropdown, Badge, Button, notification } from 'antd';
|
||||||
import { CheckOutlined, NotificationOutlined } from '@ant-design/icons';
|
import { NotificationOutlined, MonitorOutlined, FlagOutlined, ScheduleOutlined } from '@ant-design/icons';
|
||||||
import { http, X_TOKEN } from 'libs';
|
import { http, X_TOKEN } from 'libs';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import styles from './layout.module.less';
|
import styles from './layout.module.less';
|
||||||
|
@ -8,6 +8,20 @@ import styles from './layout.module.less';
|
||||||
let ws = {readyState: 3};
|
let ws = {readyState: 3};
|
||||||
let timer;
|
let timer;
|
||||||
|
|
||||||
|
|
||||||
|
function Icon(props) {
|
||||||
|
switch (props.type) {
|
||||||
|
case 'monitor':
|
||||||
|
return <MonitorOutlined style={{fontSize: 24, color: '#1890ff'}}/>
|
||||||
|
case 'schedule':
|
||||||
|
return <ScheduleOutlined style={{fontSize: 24, color: '#1890ff'}}/>
|
||||||
|
case 'flag':
|
||||||
|
return <FlagOutlined style={{fontSize: 24, color: '#1890ff'}}/>
|
||||||
|
default:
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [notifies, setNotifies] = useState([]);
|
const [notifies, setNotifies] = useState([]);
|
||||||
|
@ -63,7 +77,7 @@ export default function () {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (reads.indexOf(item.id) === -1) {
|
if (reads.indexOf(item.id) === -1) {
|
||||||
reads.push(item.id);
|
reads.push(item.id);
|
||||||
setReads(reads)
|
setReads([...reads])
|
||||||
http.patch('/api/notify/', {ids: [item.id]})
|
http.patch('/api/notify/', {ids: [item.id]})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +102,7 @@ export default function () {
|
||||||
<List.Item className={styles.item} onClick={e => handleRead(e, item)}>
|
<List.Item className={styles.item} onClick={e => handleRead(e, item)}>
|
||||||
<List.Item.Meta
|
<List.Item.Meta
|
||||||
style={{opacity: reads.includes(item.id) ? 0.4 : 1}}
|
style={{opacity: reads.includes(item.id) ? 0.4 : 1}}
|
||||||
avatar={<CheckOutlined type={item.source} style={{fontSize: 24, color: '#1890ff'}}/>}
|
avatar={<Icon type={item.source}/>}
|
||||||
title={<span style={{fontWeight: 400, color: '#404040'}}>{item.title}</span>}
|
title={<span style={{fontWeight: 400, color: '#404040'}}>{item.title}</span>}
|
||||||
description={[
|
description={[
|
||||||
<div key="1" style={{fontSize: 12}}>{item.content}</div>,
|
<div key="1" style={{fontSize: 12}}>{item.content}</div>,
|
||||||
|
@ -97,7 +111,7 @@ export default function () {
|
||||||
</List.Item>
|
</List.Item>
|
||||||
)}/>
|
)}/>
|
||||||
{notifies.length !== 0 && (
|
{notifies.length !== 0 && (
|
||||||
<div className={styles.footer} onClick={handleReadAll}>全部 已读</div>
|
<div className={styles.btn} onClick={handleReadAll}>全部 已读</div>
|
||||||
)}
|
)}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
background-color: rgb(233, 247, 254);
|
background-color: rgb(233, 247, 254);
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer {
|
.btn {
|
||||||
line-height: 46px;
|
line-height: 46px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
Loading…
Reference in New Issue