- routes.ts registers all workspaces under /console (+ detail routes, engine, audit, login) - api.ts: cookie session first (credentials include, CSRF header), Bearer only with stored key, 401 -> /login - sse.ts: shared EventSource with ?after=seq catch-up, backoff reconnect, per-type subscribe - shared components: data-table, filter-bar, detail-sheet, timeline, json-view, confirm-dialog, form-field, kv-list, stat-tile, error/loading states; ui tabs and textarea Co-Authored-By: Claude Opus 5.5 <[email protected]>
14 lines
431 B
TypeScript
14 lines
431 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import type { HealthStatus } from "@umt/contracts";
|
|
import { apiData, TTL_SECOND } from "~/lib/api.ts";
|
|
|
|
/** 服务健康状态,15 秒轮询 */
|
|
export function useHealth() {
|
|
return useQuery({
|
|
queryKey: ["health"],
|
|
queryFn: ({ signal }) => apiData<HealthStatus>("/health", { signal, noAuthRedirect: true }),
|
|
refetchInterval: 15 * TTL_SECOND,
|
|
retry: false,
|
|
});
|
|
}
|