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(() => {