Files
UHD_Media_Tool/apps/web/app/api/dashboard.ts
T
rootandClaude Opus 5.5 4bb2583f6c feat(web): status page and home regrouped around tasks, inbox and plan (FE-1)
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]>
2026-09-28 16:10:42 +08:00

27 lines
924 B
TypeScript

import { useQuery } from "@tanstack/react-query";
import { cursorPage, type Dashboard, SiteListItem } from "@umt/contracts";
import { apiData } from "~/lib/api.ts";
import { qk } from "~/lib/query-keys.ts";
import { apiParsed } from "./parse.ts";
/** 首页聚合;SSE 事件触发 invalidate,另有 60 秒兜底轮询 */
export function useDashboard() {
return useQuery({
queryKey: qk.dashboard,
queryFn: ({ signal }) => apiData<Dashboard>("/dashboard", { signal }),
refetchInterval: 60_000,
});
}
const SitePage = cursorPage(SiteListItem);
/** 首页"来源健康":站点 + 整体账号状态(GET /sites?include=accounts) */
export function useSitesWithAccounts() {
return useQuery({
queryKey: [...qk.dashboard, "sites-accounts"],
queryFn: ({ signal }) =>
apiParsed(SitePage, "/api/v1/sites", { params: { limit: 200, include: "accounts" }, signal }),
refetchInterval: 60_000,
});
}