From 9dad40f97eec9d4855ec7681fb31cf783c77e23e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E7=B6=A0BG?= Date: Wed, 11 Sep 2024 22:26:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9E=20fix=EF=BC=9A=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=8E=A5=E5=8F=A3=E6=95=B0=E6=8D=AE=E4=B8=BA=20null?= =?UTF-8?q?=20=E6=97=B6=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/components/Notification.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/modules/notification/components/Notification.tsx b/src/modules/notification/components/Notification.tsx index cfc2617..6271386 100644 --- a/src/modules/notification/components/Notification.tsx +++ b/src/modules/notification/components/Notification.tsx @@ -76,17 +76,21 @@ const Notification: React.FC = memo(() => { }; if (tab === '提问') { - const comments = res.data - .filter((item) => item.type === 'Comment') - .map((item) => JSON.parse(item.content)); + const comments = !res.data + ? res.data + .filter((item) => item.type === 'Comment') + .map((item) => JSON.parse(item.content)) + : []; setCommentMessage([ ...commentMessage, ...(await personalItems(comments, 'Comment')), ]); } else if (tab === '点赞') { - const supports = res.data - .filter((item) => item.type === 'Support') - .map((item) => JSON.parse(item.content)); + const supports = !res.data + ? res.data + .filter((item) => item.type === 'Support') + .map((item) => JSON.parse(item.content)) + : []; setSupportMessage([ ...supportMessage, ...(await personalItems(supports, 'Support')), From 81009b05f471f4ede1312926751d91d473f4cb07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E7=B6=A0BG?= Date: Wed, 11 Sep 2024 22:31:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9E=20fix=EF=BC=9A=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E8=B0=83=E6=95=B4=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/notification/components/Notification.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/notification/components/Notification.tsx b/src/modules/notification/components/Notification.tsx index 6271386..fe00947 100644 --- a/src/modules/notification/components/Notification.tsx +++ b/src/modules/notification/components/Notification.tsx @@ -76,7 +76,7 @@ const Notification: React.FC = memo(() => { }; if (tab === '提问') { - const comments = !res.data + const comments = Array.isArray(res.data) ? res.data .filter((item) => item.type === 'Comment') .map((item) => JSON.parse(item.content)) @@ -86,7 +86,7 @@ const Notification: React.FC = memo(() => { ...(await personalItems(comments, 'Comment')), ]); } else if (tab === '点赞') { - const supports = !res.data + const supports = Array.isArray(res.data) ? res.data .filter((item) => item.type === 'Support') .map((item) => JSON.parse(item.content))