Reduce hot run polling pressure

This commit is contained in:
npc0-hue
2026-09-07 20:26:20 +08:00
parent 4ab7bb820d
commit fd9dbab669
16 changed files with 335 additions and 56 deletions
+4 -1
View File
@@ -10,6 +10,9 @@ import { cx } from "../utils/classes";
type ModuleState<T> = { status: "loading" } | { status: "error"; reason: string } | { status: "ready"; data: T };
const maintenanceJobStates: JobResponse["state"][] = ["failed"];
const maintenanceJobLimit = 100;
export function MaintenancePage({ session, operations, onNavigate }: PageComponentProps) {
const [jobs, setJobs] = useState<ModuleState<JobResponse[]>>({ status: "loading" });
const [servers, setServers] = useState<ModuleState<ServerInstanceResponse[]>>({ status: "loading" });
@@ -18,7 +21,7 @@ export function MaintenancePage({ session, operations, onNavigate }: PageCompone
const refreshJobs = useCallback(async () => {
setJobs({ status: "loading" });
try {
const response = await platformApiClient.listJobs();
const response = await platformApiClient.listJobs(undefined, { states: maintenanceJobStates, limit: maintenanceJobLimit });
setJobs({ status: "ready", data: response.items });
} catch (error) {
setJobs({ status: "error", reason: error instanceof Error ? error.message : "加载失败" });