diff --git a/web/src/i18n/locales/en.json b/web/src/i18n/locales/en.json index d0077a73..f4bede2c 100644 --- a/web/src/i18n/locales/en.json +++ b/web/src/i18n/locales/en.json @@ -881,7 +881,6 @@ "你好,": "Hello,", "线路监控": "line monitoring", "查看全部": "View all", - "高延迟": "high latency", "异常": "Abnormal", "的未命名令牌": "unnamed token", "令牌更新成功!": "Token updated successfully!", @@ -1644,6 +1643,8 @@ "服务可用性": "Service Status", "可用率": "Availability", "有异常": "Abnormal", + "高延迟": "High latency", + "维护中": "Maintenance", "暂无监控数据": "No monitoring data", "请联系管理员在系统设置中配置Uptime": "Please contact the administrator to configure Uptime in the system settings." } \ No newline at end of file diff --git a/web/src/pages/Detail/index.js b/web/src/pages/Detail/index.js index 1292d337..129d82ea 100644 --- a/web/src/pages/Detail/index.js +++ b/web/src/pages/Detail/index.js @@ -846,28 +846,27 @@ const Detail = (props) => { { color: 'red', label: t('异常'), type: 'error' } ], [t]); - const uptimeLegendData = useMemo(() => [ - { color: 'green', label: t('正常'), status: 1 }, - { color: 'red', label: t('异常'), status: 0 } - ], [t]); + const uptimeStatusMap = useMemo(() => ({ + 1: { color: '#10b981', label: t('正常'), text: t('可用率') }, // UP + 0: { color: '#ef4444', label: t('异常'), text: t('有异常') }, // DOWN + 2: { color: '#f59e0b', label: t('高延迟'), text: t('高延迟') }, // PENDING + 3: { color: '#3b82f6', label: t('维护中'), text: t('维护中') } // MAINTENANCE + }), [t]); - const getUptimeStatusColor = useCallback((status) => { - switch (status) { - case 1: - return '#10b981'; // 绿色 - 正常 - default: - return '#ef4444'; // 红色 - 异常 - } - }, []); + const uptimeLegendData = useMemo(() => + Object.entries(uptimeStatusMap).map(([status, info]) => ({ + status: Number(status), + color: info.color, + label: info.label + })), [uptimeStatusMap]); - const getUptimeStatusText = useCallback((status) => { - switch (status) { - case 1: - return t('可用率'); - default: - return t('有异常'); - } - }, [t]); + const getUptimeStatusColor = useCallback((status) => + uptimeStatusMap[status]?.color || '#8b9aa7', + [uptimeStatusMap]); + + const getUptimeStatusText = useCallback((status) => + uptimeStatusMap[status]?.text || t('未知'), + [uptimeStatusMap, t]); const apiInfoData = useMemo(() => { return statusState?.status?.api_info || []; @@ -1263,38 +1262,41 @@ const Detail = (props) => { {...CARD_PROPS} className="shadow-sm !rounded-2xl lg:col-span-1" title={ -