通知中心优化

This commit is contained in:
谢思 2021-09-16 17:16:23 +08:00
parent def926bff0
commit cdc2ca755e
9 changed files with 37 additions and 14 deletions

View File

@ -369,7 +369,6 @@ class NewHeader extends Component {
let search_url = settings && settings.common && settings.common.search;
let notice_url = settings && settings.common && settings.common.notice;
console.log(current_user);
return (
<div className="newHeaders" id="nHeader">
<div className="headerContent">
@ -448,11 +447,11 @@ class NewHeader extends Component {
visible={visible}
onVisibleChange={this.handleVisibleChange}
>
<a className="message-icon" href={`/settings/notice`}>
<Link to={{pathname:"/settings/notice",state:{noticeType:"notification"}}} className="message-icon">
<Badge count={current_user.message_unread_total}>
<i className="iconfont icon-xiaoxilingdang color-grey-6 ml15 mr15"></i>
</Badge>
</a>
</Link>
</Popover>
: ""
}

View File

@ -23,6 +23,10 @@ function NoticeContent({ visible, showNotification, resetUserInfo, current_user:
const [atPage, setAtPage] = useState(0);
const [atUnreadList, setAtUnreadList] = useState([]);//@
useEffect(() => {
resetUserInfo();
}, [noticeUnreadCount,atUnreadCount]);
useEffect(() => {
const params = {
type: noticeType,
@ -86,7 +90,6 @@ function NoticeContent({ visible, showNotification, resetUserInfo, current_user:
let data = response.data;
if (!data) return;
if (data.status === 0) {
resetUserInfo();
changeReadMarkAll(noticeType);
} else {
showNotification(data.message);
@ -133,7 +136,6 @@ function NoticeContent({ visible, showNotification, resetUserInfo, current_user:
if (!data) return;
if (data.status === 0) {
changeReadMark(item);
resetUserInfo();
item.notification_url && window.open(item.notification_url);
} else {
showNotification(data.message);
@ -244,7 +246,7 @@ function NoticeContent({ visible, showNotification, resetUserInfo, current_user:
)
}) : "暂无数据" : ""} */}
<div className="hoverNotice-buttom">
<Link to="/settings/notice">全部消息</Link>
<Link to={{pathname:"/settings/notice",state:{noticeType:noticeType}}}>全部消息</Link>
{noticeUnreadCount > 0 && noticeType === "notification" && <a onClick={readAll}>所有系统消息一键已读</a>}
{atUnreadCount > 0 && noticeType === "atme" && <a onClick={readAll}>所有@我一键已读</a>}
</div>

View File

@ -181,6 +181,7 @@
position: relative;
.ant-scroll-number{
right:12px;
padding: 0 0px;
}
}

View File

@ -61,7 +61,7 @@ function Index(props){
</ul>
<ul className="securityUl ul-border-buttom">
<li>消息通知</li>
<li className={pathname.indexOf("/settings/notice")>-1 || pathname.indexOf("/settings/notice/privateLetter")>-1 ?"active":""}><Link to={`/settings/notice`}><i className="iconfont icon-wodetongzhi"></i><span className="text-shodow-bold">我的通知</span></Link></li>
<li className={pathname.indexOf("/settings/notice")>-1 || pathname.indexOf("/settings/notice/privateLetter")>-1 ?"active":""}><Link to={{pathname:"/settings/notice",state:{noticeType:"notification"}}}><i className="iconfont icon-wodetongzhi"></i><span className="text-shodow-bold">我的通知</span></Link></li>
{/* <li className={pathname.indexOf("/settings/notice/noticeManager")>-1 ?"active":""}><Link to={`/settings/notice/noticeManager`}><i className="iconfont icon-tongzhiguanli"></i><span className="text-shodow-bold">通知管理</span></Link></li> */}
</ul>
<ul className="securityUl">

View File

@ -35,7 +35,7 @@
padding-left: 17px;
color: #333;
margin-bottom: 0px;
padding-bottom: 0px;
padding-bottom: 12px;
padding-top: 5px;
li{
font-size: 14px;

View File

@ -9,11 +9,14 @@ import './Index.scss';
import '../manager/Index.scss'
function MyNotice(props) {
// console.log(props.location.state);
let current_user = props.current_user;
let resetUserInfo = props.resetUserInfo;
//tab
let popover = props.location.state && props.location.state.noticeType;
let pageSize = 15;
const [noticeType, setNoticeType] = useState("0");//tab
const [noticeType, setNoticeType] = useState(popover==="atme"?"2":"0");//tab
const [selectedNum, setSelectedNum] = useState(0);//@
const [isBatchDelete, setIsBatchDelete] = useState(false);//@
const [batchDeleteCheckedAll, setBatchDeleteCheckAll] = useState(false);//@--
@ -26,9 +29,17 @@ function MyNotice(props) {
const [currentPage, setCurrentPage] = useState(1);//
const [onlyUnread, setOnlyUnread] = useState();
useEffect(()=>{
popover==="notification" ? setNoticeType("0"):setNoticeType("2");
},[popover])
useEffect(()=>{
resetUserInfo();
},[noticeUnreadCount,atUnreadCount])
useEffect(() => {
getMessageList();
}, [noticeType, onlyUnread, currentPage])
}, [noticeType, onlyUnread, currentPage, current_user])
function getMessageList() {
const params = {
@ -58,7 +69,7 @@ function MyNotice(props) {
axios.post(`/users/${current_user.login}/messages/read.json`,params).then((response)=>{
if(response.status === 200){
getMessageList();
resetUserInfo();
//
let totlaPage = Math.ceil((messTotalCount-1)/pageSize);
setCurrentPage(currentPage>=totlaPage? totlaPage : currentPage);
@ -125,7 +136,10 @@ function MyNotice(props) {
//
let totlaPage = Math.ceil((messTotalCount-1)/pageSize);
setCurrentPage(currentPage>=totlaPage? totlaPage : currentPage);
console.log(totlaPage);
console.log(currentPage);
setSelectedNum(0);
setBatchDeleteCheckAll(false);
}
});
}

View File

@ -101,7 +101,12 @@ button:active {
&:hover .invisable-read{
display: block;
color: #466AFF;
opacity: 0.6;
cursor: pointer;
&:hover{
opacity: 1;
}
}
&:hover .timeSpan{

View File

@ -64,7 +64,7 @@ function SSH(props) {
{
list.map((i,k)=>{
return(
<List.Item>
<List.Item key={i.id}>
<img src={miyao} alt=""/>
<div>
<p className="color-grey-3"><a className="task-hide" style={{display:"block",fontWeight:"500"}} onClick={()=>{setContent(i);setVisibleDesc(true)}}>{i.name}</a></p>

View File

@ -13,10 +13,11 @@ export const noticeSourceType = {
//个人状态类通知
OrganizationJoined:"icon-xiaoxi2", // 账号被拉入组织
OrganizationLeft:"icon-xiaoxi2", // 账号被移出组织
rganizationRole:"icon-xiaoxi2", // 账号组织权限变更
OrganizationRole:"icon-xiaoxi2", // 账号组织权限变更
ProjectJoined:"icon-xiaoxi2", // 账号被拉入项目
ProjectLeft:"icon-xiaoxi2", // 账号被移出项目
ProjectRole:"icon-xiaoxi2", // 账号仓库权限变更
//其他仓库通知
ProjectDelete:"icon-daimakuicon1", // 我关注的仓库被删除
ProjectFollowed:"icon-daimakuicon1", // 我管理的仓库被关注
@ -34,6 +35,7 @@ export const noticeSourceType = {
PullRequestAtme:"icon-hebingqingqiuicon", // 在合并请求中@我
PullRequestChanged:"icon-hebingqingqiuicon", // 我创建或负责的合并请求状态变更
PullRequestJournal:"icon-hebingqingqiuicon", // 我创建或负责的合并请求有新的评论
PullRequestClosed:"icon-hebingqingqiuicon", // 提交的合并请求被拒绝
//里程碑
ProjectMilestone:"icon-lichengbeiicon", // 我管理的仓库有新的里程碑
};