From 63fc7f746a5484e0aba8302eb3a7c11602ae6120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E9=98=B3?= Date: Sun, 29 Dec 2024 00:25:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=99=BE=E5=BA=A6=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=97=A0=E6=95=B0=E6=8D=AE=E6=97=B6=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Stats/components/NewOldVisitors/index.tsx | 4 ++-- .../Stats/components/VisitorsStatisChat/index.tsx | 6 +++--- src/pages/Dashboard/components/Stats/index.tsx | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/Dashboard/components/Stats/components/NewOldVisitors/index.tsx b/src/pages/Dashboard/components/Stats/components/NewOldVisitors/index.tsx index c8f7da4..b8994e4 100644 --- a/src/pages/Dashboard/components/Stats/components/NewOldVisitors/index.tsx +++ b/src/pages/Dashboard/components/Stats/components/NewOldVisitors/index.tsx @@ -65,8 +65,8 @@ const ChartThree: React.FC = () => { const data = await response.json(); const { result } = data; - const newVisitors = result.items[1][0][1] - const oldVisitors = 100 - result.items[1][0][1] + const newVisitors = result.items[1][0][1] !== "--" ? result.items[1][0][1] : 0 + const oldVisitors = result.items[1][0][1] !== "--" ? 100 - result.items[1][0][1] : 0 setState({ series: [newVisitors, oldVisitors] }) setResult({ newVisitors, oldVisitors }) diff --git a/src/pages/Dashboard/components/Stats/components/VisitorsStatisChat/index.tsx b/src/pages/Dashboard/components/Stats/components/VisitorsStatisChat/index.tsx index 7817f75..c392e67 100644 --- a/src/pages/Dashboard/components/Stats/components/VisitorsStatisChat/index.tsx +++ b/src/pages/Dashboard/components/Stats/components/VisitorsStatisChat/index.tsx @@ -233,7 +233,7 @@ const VisitorsStatisChat = () => { useEffect(() => { setOptions((data) => ({ ...data, - xaxis: { ...options.xaxis, categories: scopeData.categories } + xaxis: { ...options.xaxis, categories: scopeData.categories || [] } })); setState((prevState) => ({ @@ -241,11 +241,11 @@ const VisitorsStatisChat = () => { series: [ { name: '访客数量', - data: scopeData.series[0], + data: scopeData.series[0] || 0, }, { name: 'IP数量', - data: scopeData.series[1], + data: scopeData.series[1] || 0, }, ], })); diff --git a/src/pages/Dashboard/components/Stats/index.tsx b/src/pages/Dashboard/components/Stats/index.tsx index 4c43377..fabc22a 100644 --- a/src/pages/Dashboard/components/Stats/index.tsx +++ b/src/pages/Dashboard/components/Stats/index.tsx @@ -70,7 +70,7 @@ export default () => { } }); - setStats({ pv, ip, bounce: bounce / count, avgTime: formatTime(avgTime / count) }) + setStats({ pv, ip, bounce: (bounce / count) || 0, avgTime: formatTime(avgTime / count) || "00:00:00" }) }; useEffect(() => {