From 0903edfd2cf8c638028427e620dc43b83197571d Mon Sep 17 00:00:00 2001 From: caishi Date: Fri, 15 Oct 2021 10:27:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AEcookie=E4=B8=BA24=E5=B0=8F?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E9=99=90=E5=88=B6=EF=BC=8C=E8=B6=85=E8=BF=87?= =?UTF-8?q?=E5=90=8E=E9=87=8D=E6=96=B0=E5=BC=B9=E5=87=BA=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/NoticeModal/SystemNotice.jsx | 32 ++++++++++--------- src/modules/tpm/TPMIndexHOC.js | 12 +------ 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/forge/Component/NoticeModal/SystemNotice.jsx b/src/forge/Component/NoticeModal/SystemNotice.jsx index 94b197480..8032d50ec 100644 --- a/src/forge/Component/NoticeModal/SystemNotice.jsx +++ b/src/forge/Component/NoticeModal/SystemNotice.jsx @@ -3,31 +3,33 @@ 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){ - setVisible(false); - hideSystemNotice(); - } - }).catch(error=>{}) - } + // 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=>{}) + // } + 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(); } return ( diff --git a/src/modules/tpm/TPMIndexHOC.js b/src/modules/tpm/TPMIndexHOC.js index ac141ef6a..c20e75b1f 100644 --- a/src/modules/tpm/TPMIndexHOC.js +++ b/src/modules/tpm/TPMIndexHOC.js @@ -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 (