forked from Gitlink/forgeplus-react
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'
|
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,
|
||||||
|
|
Loading…
Reference in New Issue