通知中心

This commit is contained in:
谢思 2021-09-12 14:47:49 +08:00
parent 4795de938e
commit 1b21d9e3fb
3 changed files with 137 additions and 284 deletions

View File

@ -6,62 +6,35 @@ import '../SecuritySetting/Index.scss';
import '../SecuritySetting/notice/myNotice/Index.scss'
import { timeAgo } from '../../common/DateUtil';
import { Link } from 'react-router-dom';
import Axios from 'axios';
function NoticeContent(props) {
const[noticeType,setNoticeType] = useState("0");
const[notice_unread_count,setNotice_unread_count]=useState(221);//
const[notice_unread_count,setNotice_unread_count]=useState();//
const[letter_unread_count,setLetter_unread_count]=useState(10);//
const[at_unread_count,setAt_unread_count]=useState(2);//@
const[notice_unread_list,setNotice_unread_list]=useState([
{
id: 11,
type: 1, //12345 ISSUE
read: 0, //01
url: "/jasder/courselist", ///issueissue/
content: "蒋宇航在 Gitlink/Gitlink 新建易修:<b>测试环境链接地址错误</b>", //<b></b>
create_time: "2019-03-04 18:08", //
},
{
id: 12,
type: 2,
read: 0,
url: "/jasder/courselist",
content: "你关注的仓库 <b>王涛/协同分析</b> 已被删除",
create_time: "2019-03-04 18:08",
},
{
id: 12,
type: 3,
read: 0,
url: "/jasder/courselist",
content: "蔡世新建易修<b> 【镜像项目-Github】私有项目 用户新建仓库,仓库转移到本地仓库的哈哈哈哈哈</b>",
create_time: "2019-03-04 18:08",
},
{
id: 12,
type: 4,
read: 0,
url: "/jasder/courselist",
content: "您的帐号<b> 小霞子1999 </b>于2021-08-11 10:52:29在非常用的IP地址113.218.1.188(湖南)",
create_time: "2019-03-04 18:08",
},
{
id: 12,
type: 5,
read: 0,
url: "/jasder/courselist",
content: "蔡世新建易修<b> 【镜像项目-Github】私有项目</b> 用户新建仓库,仓库转移到本地仓库的哈哈哈哈哈",
create_time: "2019-03-04 18:08",
},
{
id: 12,
type: 6,
read: 0,
url: "/jasder/courselist",
content: "蔡世新建易修<b> 【镜像项目-Github】私有项目 用户新建仓库,仓库转移到本地仓库的哈哈哈</b>",
create_time: "2019-03-04 18:08",
const[at_unread_count,setAt_unread_count]=useState();//@
const [message_list, setMessage_list] = useState([]);
useEffect(() => {
const params = {
type:noticeType==="0"?"notification":noticeType==="2"?"atme":"",
limit: 20,
page: 0,
}
getMessageList(params);
}, [noticeType])
function getMessageList(params) {
console.log(params);
Axios.get(`/users/yystopf/messages.json`, {
params: params,
}).then((response) => {
setNotice_unread_count(response.data.unread_notification);
setAt_unread_count(response.data.unread_atme);
setMessage_list(response.data.messages);
console.log(message_list);
})
}
]);
const[letter_unread_list,setLetter_unread_list]=useState([
{
id: 122,
@ -112,69 +85,6 @@ function NoticeContent(props) {
create_time: "2019-03-04 18:08", //
}
]);
const[at_unread_list,setAt_unread_list]=useState([
{
id: 122,
read: 0, //01
name: "蒋宇航", //@
content: "<b>钟景霞</b> 在易修 <b>【UI设计】用户public key添加功能</b> 中@我", //@<b></b>
create_time: "2019-03-04 18:08", //@
url: "/jasder/courselist", ///issue
},
{
id: 122,
read: 0, //01
name: "阿吧", //@
content: "<b>钟景霞</b> 在易修 <b>【UI设计】用户public key添加功能</b> 中@我【后端】代码库没有任何文件的情况下镜像项目创建/代码库页面一直处于loading状态需优化 ", //@<b></b>
create_time: "2019-03-04 18:08", //@
url: "/jasder/courselist", ///issue
}
,
{
id: 122,
read: 0, //01
name: "蒋宇航", //@
content: "<b>钟景霞</b> 在易修 <b>【UI设计】用s@我", //@<b></b>
create_time: "2019-03-04 18:08", //@
url: "/jasder/courselist", ///issue
}
,
{
id: 122,
read: 0, //01
name: "蒋宇航", //@
content: "<b>钟景霞</b> key添加功能</b> 中@我", //@<b></b>
create_time: "2019-03-04 18:08", //@
url: "/jasder/courselist", ///issue
}
,
{
id: 122,
read: 0, //01
name: "蒋宇航", //@
content: "<b>钟景霞</b> 在易修 <b>【UI设计】用户public key添加功能</b> 中@我axdsadasd", //@<b></b>
create_time: "2019-03-04 18:08", //@
url: "/jasder/courselist", ///issue
}
,
{
id: 122,
read: 0, //01
name: "蒋宇航", //@
content: "<b>钟景霞</b> 在易修 <b>【UI设计】用户public key添加功sdasd能</b> 中@我", //@<b></b>
create_time: "2019-03-04 18:08", //@
url: "/jasder/courselist", ///issue
}
,
{
id: 122,
read: 0, //01
name: "蒋宇航", //@
content: "<b>钟景霞</b> 在易修 <b>【UI设计】用户public key添加功能</b> 中@我", //@<b></b>
create_time: "2019-03-04 18:08", //@
url: "/jasder/courselist", ///issue
}
]);
return(
<div className="messageHoverDiv notice01">
@ -187,23 +97,38 @@ function NoticeContent(props) {
</div>
<div className="hoverNotice-body">
{/* 系统消息 */}
{noticeType==="0"?notice_unread_list.length>0?notice_unread_list.map(item=>{
{message_list.map(item=>{
//
if(noticeType ==="0" && item.type === "notification" && item.status===1){
let contentStr = item.content.endsWith("</b>") && item.content.length>=50 && item.content.replace("</b>","").substr(0,40)+"...";
let iconName = item.type===1?"icon-xitongtongzhiicon":item.type===2?"icon-xiaoxi2":item.type===3?"icon-yixiuicon1":item.type===4?"icon-hebingqingqiuicon":item.type===5?"icon-lichengbeiicon":"icon-daimakuicon1";
// let iconName = item.type===1?"icon-xitongtongzhiicon":item.type===2?"icon-xiaoxi2":item.type===3?"icon-yixiuicon1":item.type===4?"icon-hebingqingqiuicon":item.type===5?"icon-lichengbeiicon":"icon-daimakuicon1";
return(
<div className="noticeCont-back">
<div className="noticeCont" style={{height:item.content.length>=30 && item.content.length<=34?'65px':""}}>
<div className="noticeCont" style={{height:item.content.length>30 && item.content.length<=34?'65px':""}}>
<Badge color="#FA2020" />
<i className={"iconfont "+iconName}></i>
<i className="iconfont icon-yixiuicon1"></i>
<div className="noticeCont-text">
<span dangerouslySetInnerHTML={{__html:contentStr?contentStr: item.content.length>=48?item.content.substr(0,48)+"...":item.content}}></span>
<span className="timeSpan">{item.create_time?timeAgo(item.create_time):"刚刚"}</span>
<span className="timeSpan">{item.time_ago}</span>
</div>
</div>
</div>
)
}):"暂无数据":""}
}else if(noticeType ==="2" && item.type === "atme" && item.status===1){
// @
return(
<div className="noticeCont-back">
<div className="noticeCont" style={{height:item.content.length>30 && item.content.length<=42?'65px':""}}>
<Badge color="#FA2020" />
<div className="noticeCont-text">
<span dangerouslySetInnerHTML={{__html:item.content.length>=56?item.content.substr(0,56)+"...@我":item.content}}></span>
<span className="timeSpan">{item.time_ago}</span>
</div>
</div>
</div>
)
}
})}
{/* 私信 */}
{noticeType==="1"?letter_unread_list.length>0?letter_unread_list.map(item=>{
@ -220,59 +145,6 @@ function NoticeContent(props) {
</div>
)
}):"暂无数据":""}
{/* @我 */}
{noticeType==="2"?at_unread_list.length>0?at_unread_list.map(item=>{
return(
<div className="noticeCont-back">
<div className="noticeCont" style={{height:item.content.length>=30 && item.content.length<=42?'65px':""}}>
<Badge color="#FA2020" />
<div className="noticeCont-text">
{/* <span className="at-name">{item.name}</span> */}
<span dangerouslySetInnerHTML={{__html:item.content.length>=56?item.content.substr(0,56)+"...@我":item.content}}></span>
<span className="timeSpan">{item.create_time?timeAgo(item.create_time):"刚刚"}</span>
</div>
</div>
</div>
)
}):"暂无数据":""}
{/* <div className="noticeCont">
<Badge color="#FA2020" />
{noticeType === "0" ? <i className="iconfont icon-yixiuicon1"></i> : ""}
<div className="text">
<span>蒋宇航</span>
<span className="boldSpan">最好的OpenStack控制台对标Open社区项目Horizon在易...</span>
<span className="timeSpan">4分钟前</span>
</div>
</div>
<div className="noticeCont">
<Badge color="#FA2020" />
{noticeType === "0" ? <i className="iconfont icon-yixiuicon1"></i> : ""}
<div className="text">
<span>蒋宇航</span>
<span className="boldSpan">最好的OpenStack控制台对标Open社区项目Horizon在易...</span>
<span className="timeSpan">4分钟前</span>
</div>
</div>
<div className="noticeCont">
<Badge color="#FA2020" />
{noticeType === "0" ? <i className="iconfont icon-yixiuicon1"></i> : ""}
<div className="text">
<span>蒋宇航</span>
<span className="boldSpan">最好的OpenStack控制台对标Open社区项目Horizon在易...</span>
<span className="timeSpan">4分钟前</span>
</div>
</div>
<div className="noticeCont">
<Badge color="#FA2020" />
{noticeType === "0" ? <i className="iconfont icon-yixiuicon1"></i> : ""}
<div className="text">
<span>蒋宇航</span>
<span className="boldSpan">最好的OpenStack控制台对标Open社区项目Horizon在易...</span>
<span className="timeSpan">4分钟前</span>
</div>
</div> */}
</div>
<div className="hoverNotice-buttom">
<Link to="/settings/notice/myNotice">全部消息</Link>

View File

@ -3,23 +3,51 @@ import { Badge, Button, Checkbox, Menu } from 'antd';
import './Index.scss';
import '../manager/Index.scss'
import DelModal from '../../../Wiki/components/ModalFun';
import Axios from 'axios';
import { Link } from 'react-router-dom';
function MyNotice(props) {
const [noticeType, setNoticeType] = useState("2");
const [noticeType, setNoticeType] = useState("0");
const [selectedNum, setSelectedNum] = useState(0);
const [isBatchDelete, setIsBatchDelete] = useState(false);
const [notice_unread_count, setNotice_unread_count] = useState();//
const [letter_unread_count, setLetter_unread_count] = useState(0);//
const [at_unread_count, setAt_unread_count] = useState();//@
const [message_list, setMessage_list] = useState([]);
const [onlyUnread,setOnlyUnread] = useState();
useEffect(() => {
const params = {
type:noticeType==="0"?"notification":noticeType==="2"?"atme":"",
status:onlyUnread?onlyUnread:"",
limit: 20,
page: 0,
}
getMessageList(params);
}, [noticeType,onlyUnread])
function getMessageList(params) {
Axios.get(`/users/yystopf/messages.json`, {
params: params,
}).then((response) => {
setNotice_unread_count(response.data.unread_notification);
setAt_unread_count(response.data.unread_atme);
setMessage_list(response.data.messages);
})
}
function handleClick(e) {
setNoticeType(e.key);
if (e.key != "2") {
setIsBatchDelete(false);
}
}
function onChange() {
var selectedNum = 0;
const checkbox = document.getElementsByClassName("checkbox");
const checkbox = document.getElementsByClassName("atme-checkbox");
for (var i = 0; i < checkbox.length; i++) {
checkbox[i].checked ? selectedNum++ : "";
}
@ -29,7 +57,7 @@ function MyNotice(props) {
function onCheckAllChange(e) {
const checkbox = document.getElementsByClassName("checkbox");
const checkbox = document.getElementsByClassName("atme-checkbox");
for (var i = 0; i < checkbox.length; i++) {
checkbox[i].checked = e.target.checked;
}
@ -51,16 +79,16 @@ function MyNotice(props) {
<div className="notice01">
<div className="sshHead">
<Menu mode="horizontal" selectedKeys={noticeType} onClick={handleClick}>
<Menu.Item key="0"><Badge count={5}>系统通知</Badge></Menu.Item>
<Menu.Item key="1" id="item-private"><Badge count={10}>私信</Badge></Menu.Item>
<Menu.Item key="2"><Badge count={999}>@</Badge></Menu.Item>
<Menu.Item key="0"><Badge count={notice_unread_count} title="">系统通知</Badge></Menu.Item>
<Menu.Item key="1" id="item-private"><Badge count={0}>私信</Badge></Menu.Item>
<Menu.Item key="2"><Badge count={at_unread_count}>@</Badge></Menu.Item>
</Menu>
<button>所有{noticeType==="0"?"系统通知":noticeType==="1"?"私信":"@我"}一键已读</button>
<button>所有{noticeType === "0" ? "系统通知" : noticeType === "1" ? "私信" : "@我"}一键已读</button>
</div>
<div className={isBatchDelete ? "invisible " : "visible"}>
<div className="vertical-center-style">
<Checkbox >仅看未读{noticeType === "1" ? "私信" : "消息"}12</Checkbox>
<Checkbox onChange={(e)=>e.target.checked?setOnlyUnread(1):setOnlyUnread(2)}>仅看未读{noticeType === "1" ? `私信12` : noticeType==="0"?`消息(${notice_unread_count}`:`消息(${at_unread_count}`}</Checkbox>
</div>
{noticeType === "2" ? <button onClick={() => { setIsBatchDelete(true); }}>批量删除</button> : ""}
</div>
@ -71,99 +99,49 @@ function MyNotice(props) {
全选&nbsp;&nbsp;&nbsp;已选择&nbsp;<span id="numberSpan">{selectedNum}</span>&nbsp;
</div>
<div>
<button onClick={() => { setIsBatchDelete(false);setSelectedNum(0); }}>取消</button>&nbsp;&nbsp;&nbsp;&nbsp;
<button className="deleteBut" onClick={selectedNum>0 ? deleteNotice:()=>{}}>删除</button>
<button onClick={() => { setIsBatchDelete(false); setSelectedNum(0); }}>取消</button>&nbsp;&nbsp;&nbsp;&nbsp;
<button className="deleteBut" onClick={selectedNum > 0 ? deleteNotice : () => { }}>删除</button>
</div>
</div>
{noticeType === "1" ?
<div className="mynotice-content vertical-center-style">
<Badge count={95}><img src="https://testforgeplus.trustie.net//system/lets/letter_avatars/2/D/208_124_118/120.png" class="currentImg private-letter-img"/></Badge>
<div className="private-letter-right">
<div>
<span>蒋宇航</span>
<span className="timeSpan">4分钟前</span>
<a onClick={deleteNotice}>删除</a>
</div>
<div onClick={() => props.history.push('/settings/notice/privateLetter')}>
<span className="highlightSpan letter-length-limit">最好的OpenStack控制台对标OpenStack社区Horizon项目,最好的OpenStack控制台对标OpenStack社区Horizon项目在易用性页面性能等方面进行深度优化提供简单控制台</span>
</div>
</div>
</div>
: <div className="mynotice-content vertical-center-style">
{message_list.map(item => {
//
//
// const iconName = item.source.startsWith("Issue")?"icon-yixiuicon1":item.source.startsWith("Project")?"icon-daimakuicon1":item.source.startsWith("Project")?"icon-daimakuicon1":
if(noticeType ==="0" && item.type === "notification"){
return(
<div className="mynotice-content vertical-center-style" key={item.id}>
<div className="mynotice-cont vertical-center-style">
<input type="checkbox" className={isBatchDelete ? 'checkbox' : 'invisible'} onChange={onChange} />
{/* 系统通知 */}
{noticeType === "0" ? <Badge color="#FA2020" /> : ""}
{noticeType === "0" ? <i className="iconfont icon-yixiuicon1"></i> : ""}
{noticeType === "2" ? <img src="https://testforgeplus.trustie.net//system/lets/letter_avatars/2/D/208_124_118/120.png" class="currentImg"/> : ""}
{/* {noticeType === "2" ? <Badge color="#FA2020" className="at-badge"/> : ""} */}
<span className={noticeType==="0"?"sysNotice-length highlightSpan":"at-length highlightSpan"}>{noticeType === "2" ? <Badge color="#FA2020" className="at-badge"/> : ""}蒋宇航在<span className="boldSpan">Gitlink/Gitlink</span>新建易修:<span className="boldSpan">Bug链接地址错误</span></span>
{item.status === 1? <Badge color="#FA2020" />:<span className="system-notice-blank"></span>}
<i className="iconfont icon-yixiuicon1"></i>
<span className="sysNotice-length highlightSpan" onClick={()=>window.location.href=(`${item.notification_url}`)}>{item.content}</span>
</div>
<div className="mynotice-cont vertical-center-style float-left-little">
<span className="timeSpan">{item.time_ago}</span>
<a>标记为已读</a>
</div>
</div>
)
} else if(noticeType ==="2" && item.type === "atme"){
//@
return(
<div className="mynotice-content vertical-center-style" key={item.id}>
<div className="mynotice-cont vertical-center-style">
<input type="checkbox" className={isBatchDelete ? 'atme-checkbox' : 'invisible'} onChange={onChange} />
<img src={`https://testforgeplus.trustie.net//${item.sender.image_url}`} className="currentImg" />
<span className="at-length highlightSpan">
{item.status === 1? <Badge color="#FA2020" className="at-badge"/>:<span className="system-notice-blank"></span>}
{item.content}
</span>
</div>
<div className="mynotice-cont vertical-center-style">
<span className="timeSpan">4分钟前</span>
<a>标记为已读</a>&nbsp;&nbsp;&nbsp;{noticeType === "0" ? "" : <a className="float-left-little" onClick={deleteNotice}>删除</a>}
</div>
</div>}
{noticeType === "1" ?
<div className="mynotice-content vertical-center-style">
<Badge count={599}><img src="https://testforgeplus.trustie.net//system/lets/letter_avatars/2/D/208_124_118/120.png" class="currentImg private-letter-img"/></Badge>
<div className="private-letter-right">
<div>
<span>段甲生</span>
<span className="timeSpan">5分钟前</span>
<a onClick={deleteNotice}>删除</a>
</div>
<div>
<span className="highlightSpan letter-length-limit">gitlink平台 react 前端代码</span>
<span className="timeSpan">{item.time_ago}</span>
<a>标记为已读</a>&nbsp;&nbsp;&nbsp;<a className="float-left-little" onClick={deleteNotice}>删除</a>
</div>
</div>
</div>
: <div className="mynotice-content vertical-center-style">
<div className="mynotice-cont vertical-center-style">
<input type="checkbox" className={isBatchDelete ? 'checkbox' : 'invisible'} onChange={onChange} />
{/* 系统通知 */}
{noticeType === "0" ? <Badge color="#FA2020" /> : ""}
{noticeType === "0" ? <i className="iconfont icon-hebingqingqiuicon"></i> : ""}
{noticeType === "2" ? <img src="https://testforgeplus.trustie.net//system/lets/letter_avatars/2/D/208_124_118/120.png" class="currentImg"/> : ""}
{/* {noticeType === "2" ? <Badge color="#FA2020" className="at-badge"/> : ""} */}
<span className={noticeType==="0"?"sysNotice-length highlightSpan":"at-length highlightSpan"}>{noticeType === "2" ? <Badge color="#FA2020" className="at-badge"/> : ""}蒋宇航在<span className="boldSpan">蒋宇航/软件工程课程协同开发案例</span>指派给你一个合并请求<span className="boldSpan">请进行合并请求test</span>请进行合并请求test请进行合并请求test请进行合并请求test请进行合并请求test请进行合并请求test</span>
</div>
<div className="mynotice-cont vertical-center-style">
<span className="timeSpan">10分钟前</span>
<a>标记为已读</a>&nbsp;&nbsp;&nbsp;{noticeType === "0" ? "" : <a className="float-left-little" onClick={deleteNotice}>删除</a>}
</div>
</div>}
{noticeType === "1" ?
<div className="mynotice-content vertical-center-style">
<Badge count={5}><img src="https://testforgeplus.trustie.net//system/lets/letter_avatars/2/D/208_124_118/120.png" class="currentImg private-letter-img"/></Badge>
<div className="private-letter-right">
<div>
<span>巴拉迪维</span>
<span className="timeSpan">7分钟前</span>
<a onClick={deleteNotice}>删除</a>
</div>
<div>
<span className="highlightSpan letter-length-limit">构建卷积神经网络训练模型预测模型效果</span>
</div>
</div>
</div>
: <div className="mynotice-content vertical-center-style">
<div className="mynotice-cont vertical-center-style">
<input type="checkbox" className={isBatchDelete ? 'checkbox' : 'invisible'} onChange={onChange} />
{/* 系统通知 */}
{noticeType === "0" ? <span>&nbsp;&nbsp;&nbsp;</span> : ""}
{noticeType === "0" ? <i className="iconfont icon-lichengbeiicon"></i> : ""}
{noticeType === "2" ? <img src="https://testforgeplus.trustie.net//system/lets/letter_avatars/2/D/208_124_118/120.png" class="currentImg"/> : ""}
<span className={noticeType==="0"?"sysNotice-length highlightSpan":"at-length highlightSpan"}>你关注的仓库<span className="boldSpan">王涛/协同案例分析</span>已被删除</span>
</div>
<div className="mynotice-cont vertical-center-style">
<span className="timeSpan">1小时前</span>
<a>标记为已读</a>&nbsp;&nbsp;&nbsp;{noticeType === "0" ? "" : <a className="float-left-little" onClick={deleteNotice}>删除</a>}
</div>
</div>}
)
}
})}
</div>
)
}

View File

@ -127,11 +127,9 @@ button:active {
.mynotice-cont{
padding:0;
position: relative;
& .at-badge{
position: absolute;
left: 50px;
& .atme-checkbox{
margin-right: 10px;
}
}
@ -143,6 +141,10 @@ button:active {
min-width: 8px;
height: 8px;
}
& .system-notice-blank{
margin-right: 14px;
}
}
.baselineDiv{
@ -159,6 +161,7 @@ button:active {
height: 30px;
padding: 0 10px;
color: #333333;
margin-bottom: 5px;
button{
padding:0px 12px;
}
@ -193,7 +196,7 @@ button:active {
.at-length{
max-width: 48rem;
margin-left: 22px;
margin-left: 18px;
}
#numberSpan{
color: #466AFF;