From 0e31deb88cc5bba402f71fc5dee7e7921fcc9a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <792998983@qq.com> Date: Tue, 14 Sep 2021 16:33:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=80=9A=E7=9F=A5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Head/Header.js | 4 +- src/forge/Head/NoticeContent.jsx | 21 +++++--- .../SecuritySetting/notice/myNotice/Index.jsx | 50 +++---------------- src/forge/common/static.js | 39 +++++++++++++++ 4 files changed, 62 insertions(+), 52 deletions(-) create mode 100644 src/forge/common/static.js diff --git a/src/forge/Head/Header.js b/src/forge/Head/Header.js index 776e9e44f..27470ca4b 100644 --- a/src/forge/Head/Header.js +++ b/src/forge/Head/Header.js @@ -280,7 +280,7 @@ class NewHeader extends Component { }; render() { - const { match ,hisroty ,showNotification} = this.props; + const { match ,resetUserInfo ,showNotification} = this.props; let current_user = this.props.user; let { AccountProfiletype, @@ -444,7 +444,7 @@ class NewHeader extends Component { } + content={} visible={visible} onVisibleChange={this.handleVisibleChange} > diff --git a/src/forge/Head/NoticeContent.jsx b/src/forge/Head/NoticeContent.jsx index 9e5bfea5f..3f5ef254c 100644 --- a/src/forge/Head/NoticeContent.jsx +++ b/src/forge/Head/NoticeContent.jsx @@ -3,13 +3,14 @@ import { Badge, Menu } from 'antd'; import { Link } from 'react-router-dom'; import axios from 'axios'; import AppPullRefresh from './AppPullRefresh'; +import { noticeSourceType } from '../common/static'; import './header.scss'; import '../SecuritySetting/notice/manager/Index.scss'; import '../SecuritySetting/Index.scss'; import '../SecuritySetting/notice/myNotice/Index.scss'; -function NoticeContent({ showNotification, current_user: { login } }) { +function NoticeContent({ visible, showNotification, resetUserInfo, current_user: { login } }) { const [initialize, setInitialize] = useState(true); const [noticeType, setNoticeType] = useState("notification"); const [letterUnreadCount, setLetterUnreadCount] = useState(0);//未读私信数量 @@ -43,8 +44,8 @@ function NoticeContent({ showNotification, current_user: { login } }) { if (initialize) { params.type = "atme" } - getMessageList(params); - }, [reload]); + visible && getMessageList(params); + }, [reload, visible]); function getMessageList(params) { @@ -87,6 +88,7 @@ function NoticeContent({ showNotification, current_user: { login } }) { if (!data) return; if (data.status === 0) { setReload(Math.random()); + resetUserInfo(); } else { showNotification(data.message); } @@ -113,6 +115,7 @@ function NoticeContent({ showNotification, current_user: { login } }) { if (!data) return; if (data.status === 0) { changeReadMark(item); + resetUserInfo(); item.notification_url && window.open(item.notification_url); } else { showNotification(data.message); @@ -126,11 +129,17 @@ function NoticeContent({ showNotification, current_user: { login } }) { let index = noticeUnreadList.indexOf(item); list[index].status = 2; setNoticeUnreadList(list); + if (noticeUnreadCount > 0) { + setNoticeUnreadCount(noticeUnreadCount - 1); + } } else if (item.type === "atme") { let list = atUnreadList.slice(); let index = atUnreadList.indexOf(item); list[index].status = 2; setAtUnreadList(list); + if (atUnreadCount > 0) { + setAtUnreadCount(atUnreadCount - 1); + } } } @@ -149,7 +158,7 @@ function NoticeContent({ showNotification, current_user: { login } }) { className='hoverNotice-body' // 外部添加className加以区分 onPullRefresh={() => { setNoticePage(noticePage + 1); }} //触发加载ajax的function // type={2} // 传送加载组件的状态 - count={noticeUnreadCount} // 数据当前的总数量 + count={noticeUnreadList.length} // 数据当前的总数量 pageSize={10} // > { @@ -161,7 +170,7 @@ function NoticeContent({ showNotification, current_user: { login } }) { - +
= 48 ? item.content.substr(0, 48) + "..." : item.content }}> {item.time_ago} @@ -179,7 +188,7 @@ function NoticeContent({ showNotification, current_user: { login } }) { className='hoverNotice-body' // 外部添加className加以区分 onPullRefresh={() => { setAtPage(atPage + 1); }} //触发加载ajax的function // type={1} // 传送加载组件的状态 - count={atUnreadCount} // 数据当前的总数量 + count={atUnreadList.length} // 数据当前的总数量 pageSize={10} // > {atUnreadList.map(item => { diff --git a/src/forge/SecuritySetting/notice/myNotice/Index.jsx b/src/forge/SecuritySetting/notice/myNotice/Index.jsx index bb19a60fe..0f28b32c2 100644 --- a/src/forge/SecuritySetting/notice/myNotice/Index.jsx +++ b/src/forge/SecuritySetting/notice/myNotice/Index.jsx @@ -1,17 +1,18 @@ import React, { useState, useEffect } from 'react'; +import { Link } from 'react-router-dom'; +import axios from 'axios'; import { Badge, Button, Checkbox, Menu, Pagination } from 'antd'; +import DelModal from '../../../Component/ModalFun'; +import NoneData from '../../../Nodata.js'; +import { noticeSourceType } from '../../../common/static'; import './Index.scss'; import '../manager/Index.scss' -import DelModal from '../../../Wiki/components/ModalFun'; -import axios from 'axios'; -import { Link } from 'react-router-dom'; -import NoneData from '../../../Nodata.js'; function MyNotice(props) { let current_user = props.current_user; let pageSize = 20; - const [noticeType, setNoticeType] = useState("2");//消息类别tab栏选择 + const [noticeType, setNoticeType] = useState("0");//消息类别tab栏选择 const [selectedNum, setSelectedNum] = useState(0);//@我批量删除选择消息条数 const [isBatchDelete, setIsBatchDelete] = useState(false);//@我是否批量删除 const [batchDeleteCheckedAll, setBatchDeleteCheckAll] = useState(false);//@我批量删除--全选 @@ -23,45 +24,6 @@ function MyNotice(props) { const [messTotalCount, setMessTotalCount] = useState();//消息总数 const [currentPage, setCurrentPage] = useState(1);//当前页数 const [onlyUnread, setOnlyUnread] = useState(); - const noticeSourceType = { - // 易修 - IssueAssigned:"icon-yixiuicon1", // 有新指派给我的易修 - IssueAssignerExpire:"icon-yixiuicon1", // 我负责的易修截止日期到达最后一天 - IssueAtme:"icon-yixiuicon1", // 在易修中@我 - IssueChanged:"icon-yixiuicon1", // 我创建或负责的易修状态变更 - IssueCreatorExpire:"icon-yixiuicon1", // 我创建的易修截止日期到达最后一天 - IssueDelete:"icon-yixiuicon1", // 我创建或负责的易修删除 - IssueDeleted:"icon-yixiuicon1", // 我创建或负责的易修删除 - IssueJournal:"icon-yixiuicon1", // 我创建或负责的易修有新的评论 - //平台通知 - LoginIpTip:"icon-xitongtongzhiicon", //登录异常提示 - //个人状态类通知 - OrganizationJoined:"icon-xiaoxi2", // 账号被拉入组织 - OrganizationLeft:"icon-xiaoxi2", // 账号被移出组织 - rganizationRole:"icon-xiaoxi2", // 账号组织权限变更 - ProjectJoined:"icon-xiaoxi2", // 账号被拉入项目 - ProjectLeft:"icon-xiaoxi2", // 账号被移出项目 - ProjectRole:"icon-xiaoxi2", // 账号仓库权限变更 - //其他仓库通知 - ProjectDelete:"icon-daimakuicon1", // 我关注的仓库被删除 - ProjectFollowed:"icon-daimakuicon1", // 我管理的仓库被关注 - ProjectForked:"icon-daimakuicon1", // 我管理的仓库被复刻 - ProjectIssue:"icon-daimakuicon1", // 我管理/关注的仓库有新的易修 - ProjectSettingChanged:"icon-daimakuicon1", // 我管理的仓库项目设置被更改 - ProjectTransfer:"icon-daimakuicon1", // 我关注的仓库被转移 - ProjectVersion:"icon-daimakuicon1", // 我关注的仓库有新的发行版 - ProjectMemberJoined:"icon-daimakuicon1", // 我管理的仓库有成员加入 - ProjectMemberLeft:"icon-daimakuicon1", // 我管理的仓库有成员移出 - ProjectPraised:"icon-daimakuicon1", // 我管理的仓库被点赞 - //合并请求类通知 - ProjectPullRequest:"icon-hebingqingqiuicon", // 我管理/关注的仓库有新的合并请求 - PullRequestAssigned:"icon-hebingqingqiuicon", // 有新指派给我的合并请求 - PullRequestAtme:"icon-hebingqingqiuicon", // 在合并请求中@我 - PullRequestChanged:"icon-hebingqingqiuicon", // 我创建或负责的合并请求状态变更 - PullRequestJournal:"icon-hebingqingqiuicon", // 我创建或负责的合并请求有新的评论 - //里程碑 - ProjectMilestone:"icon-lichengbeiicon", // 我管理的仓库有新的里程碑 - }; useEffect(() => { // const params = { diff --git a/src/forge/common/static.js b/src/forge/common/static.js new file mode 100644 index 000000000..f924e0968 --- /dev/null +++ b/src/forge/common/static.js @@ -0,0 +1,39 @@ +export const noticeSourceType = { + // 易修 + IssueAssigned:"icon-yixiuicon1", // 有新指派给我的易修 + IssueAssignerExpire:"icon-yixiuicon1", // 我负责的易修截止日期到达最后一天 + IssueAtme:"icon-yixiuicon1", // 在易修中@我 + IssueChanged:"icon-yixiuicon1", // 我创建或负责的易修状态变更 + IssueCreatorExpire:"icon-yixiuicon1", // 我创建的易修截止日期到达最后一天 + IssueDelete:"icon-yixiuicon1", // 我创建或负责的易修删除 + IssueDeleted:"icon-yixiuicon1", // 我创建或负责的易修删除 + IssueJournal:"icon-yixiuicon1", // 我创建或负责的易修有新的评论 + //平台通知 + LoginIpTip:"icon-xitongtongzhiicon", //登录异常提示 + //个人状态类通知 + OrganizationJoined:"icon-xiaoxi2", // 账号被拉入组织 + OrganizationLeft:"icon-xiaoxi2", // 账号被移出组织 + rganizationRole:"icon-xiaoxi2", // 账号组织权限变更 + ProjectJoined:"icon-xiaoxi2", // 账号被拉入项目 + ProjectLeft:"icon-xiaoxi2", // 账号被移出项目 + ProjectRole:"icon-xiaoxi2", // 账号仓库权限变更 + //其他仓库通知 + ProjectDelete:"icon-daimakuicon1", // 我关注的仓库被删除 + ProjectFollowed:"icon-daimakuicon1", // 我管理的仓库被关注 + ProjectForked:"icon-daimakuicon1", // 我管理的仓库被复刻 + ProjectIssue:"icon-daimakuicon1", // 我管理/关注的仓库有新的易修 + ProjectSettingChanged:"icon-daimakuicon1", // 我管理的仓库项目设置被更改 + ProjectTransfer:"icon-daimakuicon1", // 我关注的仓库被转移 + ProjectVersion:"icon-daimakuicon1", // 我关注的仓库有新的发行版 + ProjectMemberJoined:"icon-daimakuicon1", // 我管理的仓库有成员加入 + ProjectMemberLeft:"icon-daimakuicon1", // 我管理的仓库有成员移出 + ProjectPraised:"icon-daimakuicon1", // 我管理的仓库被点赞 + //合并请求类通知 + ProjectPullRequest:"icon-hebingqingqiuicon", // 我管理/关注的仓库有新的合并请求 + PullRequestAssigned:"icon-hebingqingqiuicon", // 有新指派给我的合并请求 + PullRequestAtme:"icon-hebingqingqiuicon", // 在合并请求中@我 + PullRequestChanged:"icon-hebingqingqiuicon", // 我创建或负责的合并请求状态变更 + PullRequestJournal:"icon-hebingqingqiuicon", // 我创建或负责的合并请求有新的评论 + //里程碑 + ProjectMilestone:"icon-lichengbeiicon", // 我管理的仓库有新的里程碑 +}; \ No newline at end of file