Merge pull request '处理未登录状态下地址栏输入跳转消息页面情况' (#157) from durian/forgeplus-react:pre_develop_dev into pre_develop_dev
This commit is contained in:
commit
095e27fcc3
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue