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 './Index.scss';
|
||||||
import '../../css/index.scss';
|
import '../../css/index.scss';
|
||||||
import RenderHtml from '../../../components/render-html';
|
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);
|
const [ visible , setVisible ] = useState(false);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(system_notification && !system_notification.is_read && showNotice){
|
if(system_notification && !cookie.load('notice_stage')){
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
},[system_notification])
|
},[system_notification])
|
||||||
|
|
||||||
function sureContinue() {
|
function sureContinue() {
|
||||||
if(login && ( system_notification && system_notification.id )){
|
// if(login && ( system_notification && system_notification.id )){
|
||||||
const url = `/users/${login}/system_notification_histories.json`;
|
// const url = `/users/${login}/system_notification_histories.json`;
|
||||||
axios.post(url,{
|
// axios.post(url,{
|
||||||
system_notification_id:system_notification.id
|
// system_notification_id:system_notification.id
|
||||||
}).then(result=>{
|
// }).then(result=>{
|
||||||
if(result && result.status === 0){
|
// 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);
|
setVisible(false);
|
||||||
hideSystemNotice();
|
|
||||||
}
|
|
||||||
}).catch(error=>{})
|
|
||||||
}
|
|
||||||
setVisible(false);
|
|
||||||
hideSystemNotice();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -29,7 +29,6 @@ export function TPMIndexHOC(WrappedComponent) {
|
||||||
email:undefined,
|
email:undefined,
|
||||||
completeProfile:false,
|
completeProfile:false,
|
||||||
showCP:false,
|
showCP:false,
|
||||||
showNotice:true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,15 +215,8 @@ export function TPMIndexHOC(WrappedComponent) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
hideSystemNotice=()=>{
|
|
||||||
this.setState({
|
|
||||||
showNotice:false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
render() {
|
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 = {
|
const common = {
|
||||||
showLoginDialog: this.showLoginDialog,
|
showLoginDialog: this.showLoginDialog,
|
||||||
checkIfLogin: this.checkIfLogin,
|
checkIfLogin: this.checkIfLogin,
|
||||||
|
@ -234,11 +226,9 @@ export function TPMIndexHOC(WrappedComponent) {
|
||||||
return (
|
return (
|
||||||
<div className="indexHOC">
|
<div className="indexHOC">
|
||||||
<SystemNotice
|
<SystemNotice
|
||||||
showNotice={showNotice}
|
|
||||||
system_notification={mygetHelmetapi && mygetHelmetapi.system_notification}
|
system_notification={mygetHelmetapi && mygetHelmetapi.system_notification}
|
||||||
history={this.props.history}
|
history={this.props.history}
|
||||||
login={current_user && current_user.login}
|
login={current_user && current_user.login}
|
||||||
hideSystemNotice={this.hideSystemNotice}
|
|
||||||
/>
|
/>
|
||||||
<EducoderAccount visible={giteaVisible} email={email} onOk={this.onOk}/>
|
<EducoderAccount visible={giteaVisible} email={email} onOk={this.onOk}/>
|
||||||
<ProfileModal
|
<ProfileModal
|
||||||
|
|
Loading…
Reference in New Issue