forked from Gitlink/forgeplus-react
Merge pull request '弹框弹出时间用cookie保存' (#173) from caishi/forgeplus-react:featrue_system_popup_notification into featrue_system_popup_notification
This commit is contained in:
commit
f97c90f20e
|
@ -3,31 +3,34 @@ import { Modal , Button } from 'antd';
|
|||
import './Index.scss';
|
||||
import '../../css/index.scss';
|
||||
import RenderHtml from '../../../components/render-html';
|
||||
import axios from 'axios';
|
||||
import cookie from 'react-cookies';
|
||||
|
||||
function SystemNotice({system_notification,history,login,showNotice,hideSystemNotice}){
|
||||
function SystemNotice({system_notification,history}){
|
||||
const [ visible , setVisible ] = useState(false);
|
||||
|
||||
useEffect(()=>{
|
||||
if(system_notification && !system_notification.is_read && showNotice){
|
||||
if(system_notification && !cookie.load('notice_stage')){
|
||||
setVisible(true);
|
||||
}
|
||||
},[system_notification])
|
||||
|
||||
function sureContinue() {
|
||||
if(login && ( system_notification && system_notification.id )){
|
||||
const url = `/users/${login}/system_notification_histories.json`;
|
||||
axios.post(url,{
|
||||
system_notification_id:system_notification.id
|
||||
}).then(result=>{
|
||||
if(result && result.status === 0){
|
||||
// if(login && ( system_notification && system_notification.id )){
|
||||
// const url = `/users/${login}/system_notification_histories.json`;
|
||||
// axios.post(url,{
|
||||
// system_notification_id:system_notification.id
|
||||
// }).then(result=>{
|
||||
// if(result && result.status === 0){
|
||||
// setVisible(false);
|
||||
// hideSystemNotice();
|
||||
// }
|
||||
// }).catch(error=>{})
|
||||
// }
|
||||
cookie.remove('notice_stage');
|
||||
let inFifteenMinutes = new Date(new Date().getTime() + 24 * 3600 * 1000);//一天
|
||||
cookie.save('notice_stage', true,{ expires: inFifteenMinutes });
|
||||
console.log("cookies:",cookie.load('notice_stage')) ;
|
||||
setVisible(false);
|
||||
hideSystemNotice();
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
setVisible(false);
|
||||
hideSystemNotice();
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -29,7 +29,6 @@ export function TPMIndexHOC(WrappedComponent) {
|
|||
email:undefined,
|
||||
completeProfile:false,
|
||||
showCP:false,
|
||||
showNotice:true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,15 +215,8 @@ export function TPMIndexHOC(WrappedComponent) {
|
|||
})
|
||||
}
|
||||
|
||||
hideSystemNotice=()=>{
|
||||
this.setState({
|
||||
showNotice:false
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
let { isRender , current_user , giteaVisible , email , completeProfile , showCP , showNotice , mygetHelmetapi } = this.state;
|
||||
let { isRender , current_user , giteaVisible , email , completeProfile , showCP , mygetHelmetapi } = this.state;
|
||||
const common = {
|
||||
showLoginDialog: this.showLoginDialog,
|
||||
checkIfLogin: this.checkIfLogin,
|
||||
|
@ -234,11 +226,9 @@ export function TPMIndexHOC(WrappedComponent) {
|
|||
return (
|
||||
<div className="indexHOC">
|
||||
<SystemNotice
|
||||
showNotice={showNotice}
|
||||
system_notification={mygetHelmetapi && mygetHelmetapi.system_notification}
|
||||
history={this.props.history}
|
||||
login={current_user && current_user.login}
|
||||
hideSystemNotice={this.hideSystemNotice}
|
||||
/>
|
||||
<EducoderAccount visible={giteaVisible} email={email} onOk={this.onOk}/>
|
||||
<ProfileModal
|
||||
|
|
Loading…
Reference in New Issue