From 5c819070bb34b3f00ce19b43db14e3deff0bdf57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Wed, 13 Oct 2021 16:45:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=9C=AA=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8B=E5=9C=B0=E5=9D=80=E6=A0=8F=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E8=B7=B3=E8=BD=AC=E6=B6=88=E6=81=AF=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SecuritySetting/notice/myNotice/Index.jsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/forge/SecuritySetting/notice/myNotice/Index.jsx b/src/forge/SecuritySetting/notice/myNotice/Index.jsx index 2de2b8c3..2dac567f 100644 --- a/src/forge/SecuritySetting/notice/myNotice/Index.jsx +++ b/src/forge/SecuritySetting/notice/myNotice/Index.jsx @@ -9,10 +9,9 @@ import './Index.scss'; import '../manager/Index.scss' function MyNotice(props) { - let current_user = props.current_user; - let resetUserInfo = props.resetUserInfo; + let { current_user, resetUserInfo, location, mygetHelmetapi, history}= props; //消息悬停框选择tab - let popover = props.location.query && props.location.query.noticeType; + let popover = location && location.query && location.query.noticeType; let pageSize = 15; const [noticeType, setNoticeType] = useState(popover==="atme"?"2":"0");//消息类别tab栏选择 const [selectedNum, setSelectedNum] = useState(0);//@我批量删除选择消息条数 @@ -27,6 +26,17 @@ function MyNotice(props) { const [currentPage, setCurrentPage] = useState(1);//当前页数 const [onlyUnread, setOnlyUnread] = useState(); + //登录情况下,通过地址访问,直接跳转:/settings/profile + //未登录情况下,通过地址访问,直接跳转:/explore + useEffect(()=>{ + let notice_url = mygetHelmetapi && mygetHelmetapi.common && mygetHelmetapi.common.notice; + if(!current_user){ + history.push(`/explore`); + }else if(!notice_url){ + history.push(`/settings/profile`); + } + },[mygetHelmetapi]) + useEffect(()=>{ popover==="atme" ? setNoticeType("2"):setNoticeType("0"); },[popover]) @@ -46,7 +56,7 @@ function MyNotice(props) { limit: pageSize, page: currentPage, }; - axios.get(`/users/${current_user.login}/messages.json`, { + current_user && axios.get(`/users/${current_user.login}/messages.json`, { params: params, }).then((response) => { if(response && response.data){ @@ -59,7 +69,7 @@ function MyNotice(props) { } function readNotice(id){ - if(id){ + if(id && current_user){ const params = { type: noticeType === "0" ? "notification" : noticeType === "2" ? "atme" : "", ids:id,