添加空值检查防止 undefined 错误
This commit is contained in:
@@ -518,7 +518,8 @@ function updateMapOption() {
|
||||
if (!chartInstance)
|
||||
return
|
||||
|
||||
const data = provinces.value.filter((d: any) => d.count > 0)
|
||||
const provincesData = provinces.value || []
|
||||
const data = provincesData.filter((d: any) => d.count > 0)
|
||||
const maxCount = Math.max(...data.map((d: any) => d.count || 0), 1)
|
||||
|
||||
const dark = isDark.value
|
||||
@@ -644,8 +645,9 @@ function initActivityChart() {
|
||||
return date.toLocaleDateString('zh-CN', { month: '2-digit', day: '2-digit' })
|
||||
})
|
||||
|
||||
const data = onlineTrendData.value.length > 0
|
||||
? onlineTrendData.value
|
||||
const trendData = onlineTrendData.value || []
|
||||
const data = trendData.length > 0
|
||||
? trendData
|
||||
: Array.from({ length: 30 }).fill(0)
|
||||
|
||||
if (activityChartInstance) {
|
||||
|
||||
Reference in New Issue
Block a user