1
0

feat: 动态粒度趋势图,支持 auto bucket 选择 + P95 延迟 + 状态条

This commit is contained in:
2026-05-23 23:53:18 +08:00
parent 6601ab458d
commit 4f33fba793
16 changed files with 315 additions and 106 deletions

View File

@@ -1,11 +1,11 @@
import { useQuery } from "@tanstack/react-query";
import type { DashboardResponse, MetaResponse, TargetMetricsResponse } from "../../shared/api";
import type { DashboardResponse, MetaResponse, MetricsBucket, TargetMetricsResponse } from "../../shared/api";
const queryKeys = {
dashboard: () => ["dashboard", "24h", 30] as const,
meta: () => ["meta"] as const,
metrics: (targetId: string, from: string, to: string, bucket: "1h") =>
metrics: (targetId: string, from: string, to: string, bucket: "auto" | MetricsBucket) =>
["metrics", targetId, from, to, bucket] as const,
};
@@ -32,7 +32,7 @@ export function useMeta() {
});
}
export function useTargetMetrics(targetId: null | string, from: string, to: string, bucket: "1h") {
export function useTargetMetrics(targetId: null | string, from: string, to: string, bucket: "auto" | MetricsBucket) {
return useQuery({
enabled: targetId !== null && !!from && !!to,
queryFn: () => {

View File

@@ -23,7 +23,7 @@ export function useTargetDetail() {
? (dashboardData?.targets.find((target) => target.id === selectedTargetId) ?? null)
: null;
const metrics = useTargetMetrics(selectedTargetId, timeFrom, timeTo, "1h");
const metrics = useTargetMetrics(selectedTargetId, timeFrom, timeTo, "auto");
const history = useQuery({
enabled: selectedTargetId !== null && !!timeFrom && !!timeTo && activeTab === "history",