From 276948dd68c86d9bb5a963a729fdad15970e123a Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 12 Aug 2025 15:28:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E7=8E=87=E8=AE=A1=E7=AE=97=E5=92=8C=E7=BB=9F=E8=AE=A1=E6=80=BB?= =?UTF-8?q?=E8=A7=88=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dialog/SiteStatisticsDialog.vue | 43 +++++++++++-------- src/views/setting/AccountSettingSite.vue | 3 +- 2 files changed, 27 insertions(+), 19 deletions(-) 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(() => {
-
{{ siteStats.length }}
+
{{ overviewCounts.total }}
{{ t('site.totalSites') }}
-
- {{ siteStats.filter(s => s.lst_state === 0).length }} -
+
{{ overviewCounts.connected }}
{{ t('site.normalSites') }}
-
- {{ siteStats.filter(s => s.lst_state === 0 && s.seconds && s.seconds >= 5).length }} -
+
{{ overviewCounts.slow }}
{{ t('site.slowSites') }}
-
- {{ siteStats.filter(s => s.lst_state === 1).length }} -
+
{{ overviewCounts.failed }}
{{ t('site.failedSites') }}
@@ -270,13 +285,7 @@ onMounted(() => {
-
- {{ - item.stats?.success && item.stats?.fail - ? Math.round((item.stats.success / (item.stats.success + item.stats.fail)) * 100) - : '-' - }}% -
+
{{ getSuccessRate(item.stats) }}%
{{ t('site.successRate') }}
diff --git a/src/views/setting/AccountSettingSite.vue b/src/views/setting/AccountSettingSite.vue index eb3bc38b..20e6f835 100644 --- a/src/views/setting/AccountSettingSite.vue +++ b/src/views/setting/AccountSettingSite.vue @@ -239,10 +239,9 @@ onMounted(() => { prepend-inner-icon="mdi-web" /> - +