diff --git a/internal/handler/agent_handler.go b/internal/handler/agent_handler.go index 175b978..2ba2457 100644 --- a/internal/handler/agent_handler.go +++ b/internal/handler/agent_handler.go @@ -297,8 +297,6 @@ func (h *AgentHandler) GetMetrics(c echo.Context) error { start = end - 3*24*60*60*1000 case "7d", "1w": start = end - 7*24*60*60*1000 - case "30d", "1M": - start = end - 30*24*60*60*1000 default: return orz.NewError(400, "无效的时间范围,支持: 1h, 6h, 12h, 24h, 3d, 7d, 30d, 90d") } diff --git a/internal/service/agent_service.go b/internal/service/agent_service.go index c8ad5b6..13f604d 100644 --- a/internal/service/agent_service.go +++ b/internal/service/agent_service.go @@ -554,8 +554,8 @@ func (s *AgentService) StartCleanupTask(ctx context.Context) { // cleanupOldMetrics 清理旧数据 func (s *AgentService) cleanupOldMetrics(ctx context.Context) { - // 删除30天前的数据 - before := time.Now().AddDate(0, 0, -30).UnixMilli() + // 删除7天前的数据 + before := time.Now().AddDate(0, 0, -7).UnixMilli() s.logger.Info("starting to clean old metrics", zap.Int64("beforeTimestamp", before)) diff --git a/web/src/pages/Public/ServerDetail.tsx b/web/src/pages/Public/ServerDetail.tsx index 0edbae1..dcec27a 100644 --- a/web/src/pages/Public/ServerDetail.tsx +++ b/web/src/pages/Public/ServerDetail.tsx @@ -79,7 +79,6 @@ const timeRangeOptions = [ {label: '24小时', value: '24h'}, {label: '3天', value: '3d'}, {label: '7天', value: '7d'}, - {label: '30天', value: '30d'}, ] as const; const LoadingSpinner = () => ( @@ -173,8 +172,8 @@ const TimeRangeSelector = ({ value, onChange, }: { - value: '1h' | '6h' | '12h' | '24h' | '1d' | '3d' | '7d' | '1w' | '30d' | '1M' | '90d' | '3M'; - onChange: (value: '1h' | '6h' | '12h' | '24h' | '1d' | '3d' | '7d' | '1w' | '30d' | '1M' | '90d' | '3M') => void; + value: '1h' | '6h' | '12h' | '24h' | '1d' | '3d' | '7d'; + onChange: (value: '1h' | '6h' | '12h' | '24h' | '1d' | '3d' | '7d') => void; }) => (
{timeRangeOptions.map((option) => { @@ -247,7 +246,7 @@ const ServerDetail = () => { const [loading, setLoading] = useState(true); const [agent, setAgent] = useState(null); const [latestMetrics, setLatestMetrics] = useState(null); - const [timeRange, setTimeRange] = useState<'1h' | '6h' | '12h' | '24h' | '1d' | '3d' | '7d' | '1w' | '30d' | '1M' | '90d' | '3M'>('1h'); + const [timeRange, setTimeRange] = useState<'1h' | '6h' | '12h' | '24h' | '1d' | '3d' | '7d'>('1h'); const [selectedInterface, setSelectedInterface] = useState('all'); const [metricsData, setMetricsData] = useState<{ cpu: AggregatedCPUMetric[]; @@ -639,9 +638,6 @@ const ServerDetail = () => { const lastSeenDisplay = agent ? formatDateTime(agent.lastSeenAt) : '-'; const displayName = agent?.name?.trim() ? agent.name : '未命名探针'; const isOnline = agent?.status === 1; - const statusStyles = isOnline - ? 'inline-flex items-center gap-1 rounded-full bg-emerald-50 px-2 py-0.5 text-xs font-medium text-emerald-600' - : 'inline-flex items-center gap-1 rounded-full bg-slate-100 px-2 py-0.5 text-xs font-medium text-slate-500'; const statusDotStyles = isOnline ? 'bg-emerald-500' : 'bg-slate-400'; const statusText = isOnline ? '在线' : '离线';