Status page reads /system/health and history: level banner, process table, event-loop lag and SSE charts (monochrome recharts), database, engine, schedules, disks with thresholds and mount roots. Home now shows in-progress tasks, items needing attention, media overview, a plan strip with quick toggles, recent finished/failed tasks, cache and retention, source health with site account status, and a run-status summary. Co-Authored-By: Claude Opus 5.5 <[email protected]>
23 lines
807 B
TypeScript
23 lines
807 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import type { SystemHealth, SystemHealthHistory } from "@umt/contracts";
|
|
import { apiData } from "~/lib/api.ts";
|
|
import { qk } from "~/lib/query-keys.ts";
|
|
|
|
// 进程与健康(W9-I):GET /system/health、/system/health/history,仅 admin。
|
|
|
|
export function useSystemHealth(refetchMs = 15_000) {
|
|
return useQuery({
|
|
queryKey: qk.sub("system", "health"),
|
|
queryFn: ({ signal }) => apiData<SystemHealth>("/system/health", { signal }),
|
|
refetchInterval: refetchMs,
|
|
});
|
|
}
|
|
|
|
export function useSystemHealthHistory(hours: number) {
|
|
return useQuery({
|
|
queryKey: qk.sub("system", "history", hours),
|
|
queryFn: ({ signal }) => apiData<SystemHealthHistory>("/system/health/history", { params: { hours }, signal }),
|
|
refetchInterval: 60_000,
|
|
});
|
|
}
|