Merge pull request '处理未登录状态下地址栏输入跳转消息页面情况' (#157) from durian/forgeplus-react:pre_develop_dev into pre_develop_dev

This commit is contained in:
baladiwei 2021-10-13 16:49:24 +08:00
commit 095e27fcc3
1 changed files with 15 additions and 5 deletions

View File

@ -9,10 +9,9 @@ import './Index.scss';
import '../manager/Index.scss' import '../manager/Index.scss'
function MyNotice(props) { function MyNotice(props) {
let current_user = props.current_user; let { current_user, resetUserInfo, location, mygetHelmetapi, history}= props;
let resetUserInfo = props.resetUserInfo;
//tab //tab
let popover = props.location.query && props.location.query.noticeType; let popover = location && location.query && location.query.noticeType;
let pageSize = 15; let pageSize = 15;
const [noticeType, setNoticeType] = useState(popover==="atme"?"2":"0");//tab const [noticeType, setNoticeType] = useState(popover==="atme"?"2":"0");//tab
const [selectedNum, setSelectedNum] = useState(0);//@ const [selectedNum, setSelectedNum] = useState(0);//@
@ -27,6 +26,17 @@ function MyNotice(props) {
const [currentPage, setCurrentPage] = useState(1);// const [currentPage, setCurrentPage] = useState(1);//
const [onlyUnread, setOnlyUnread] = useState(); 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(()=>{ useEffect(()=>{
popover==="atme" ? setNoticeType("2"):setNoticeType("0"); popover==="atme" ? setNoticeType("2"):setNoticeType("0");
},[popover]) },[popover])
@ -46,7 +56,7 @@ function MyNotice(props) {
limit: pageSize, limit: pageSize,
page: currentPage, page: currentPage,
}; };
axios.get(`/users/${current_user.login}/messages.json`, { current_user && axios.get(`/users/${current_user.login}/messages.json`, {
params: params, params: params,
}).then((response) => { }).then((response) => {
if(response && response.data){ if(response && response.data){
@ -59,7 +69,7 @@ function MyNotice(props) {
} }
function readNotice(id){ function readNotice(id){
if(id){ if(id && current_user){
const params = { const params = {
type: noticeType === "0" ? "notification" : noticeType === "2" ? "atme" : "", type: noticeType === "0" ? "notification" : noticeType === "2" ? "atme" : "",
ids:id, ids:id,