diff --git a/src/components/dialog/SiteStatisticsDialog.vue b/src/components/dialog/SiteStatisticsDialog.vue index 35957c84..de970368 100644 --- a/src/components/dialog/SiteStatisticsDialog.vue +++ b/src/components/dialog/SiteStatisticsDialog.vue @@ -117,6 +117,16 @@ function getTimeColor(seconds: number | undefined): string { return 'error' } +// 获取成功率(与列表/概览口径一致) +function getSuccessRate(stats: SiteStatistic | undefined): string { + if (!stats) return '-' + const success = Number(stats.success ?? 0) + const fail = Number(stats.fail ?? 0) + const total = success + fail + if (total <= 0) return '-' + return String(Math.round((success / total) * 100)) +} + // 解析耗时记录 function parseTimeRecords(note: any): Array<{ time: string; duration: number }> { if (!note) return [] @@ -178,6 +188,17 @@ const sortedSites = computed(() => { }) }) +// 统计总览(与列表口径一致) +const overviewCounts = computed(() => { + const items = sortedSites.value + const total = items.length + const connected = items.filter(i => i.status === 'connected').length + const slow = items.filter(i => i.status === 'slow').length + const failed = items.filter(i => i.status === 'failed').length + const unknown = total - connected - slow - failed + return { total, connected, slow, failed, unknown } +}) + onMounted(() => { fetchSiteStats() }) @@ -206,25 +227,19 @@ onMounted(() => {