From fe1bacb98417a88453e9b72f48e48b462133716b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Tue, 19 Oct 2021 10:26:36 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E7=AE=A1=E7=90=86+=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=9F=BA=E6=9C=AC=E8=B5=84=E6=96=99=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9A=84consolo=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SecuritySetting/notice/manager/Index.jsx | 46 +++++++++++-------- src/forge/users/Material/Base.jsx | 1 - 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/forge/SecuritySetting/notice/manager/Index.jsx b/src/forge/SecuritySetting/notice/manager/Index.jsx index d45dc3713..ca16f25ec 100644 --- a/src/forge/SecuritySetting/notice/manager/Index.jsx +++ b/src/forge/SecuritySetting/notice/manager/Index.jsx @@ -10,26 +10,36 @@ function NoticeManager(props){ const [userNotification, setUserNotification] = useState(); const [userEmail, setUserEmail] = useState(); - function getUserSettings(){ + function onChange(type,e,setting){ + let notification_body = userNotification; + let email_body = userEmail; + if(type){//站内信 + notification_body[setting] = e.target.checked; + }else{//邮件 + email_body[setting] = e.target.checked; + } + axios.post(`/users/${current_user.login}/template_message_settings/update_setting.json`,{ + setting:{ + notification_body:notification_body, + email_body:email_body + } + }) + } + + useEffect(()=>{ + axios.get("/template_message_settings.json").then(response => { + if (response && response.status === 200) { + setSettingTypes(response.data.setting_types); + } + }) axios.get(`/users/${current_user.login}/template_message_settings.json`).then((response)=>{ if(response && response.status === 200 ){ setUserEmail(response.data.email_body); setUserNotification(response.data.notification_body); } }) - } - - useEffect(()=>{ - axios.get("/template_message_settings.json").then((response)=>{ - if(response && response.status === 200 ){ - setSettingTypes(response.data.setting_types); - } - }) - getUserSettings(); },[]) - console.log('settingTypes',settingTypes); - console.log('userNotification',userNotification,'userEmail',userEmail); return(