| 1234567891011121314151617 |
- import type { RunGraph, RunSummary } from "@/lib/types";
- const API_BASE = process.env.NEXT_PUBLIC_API_BASE ?? "http://127.0.0.1:8788";
- async function getJson<T>(path: string, signal?: AbortSignal): Promise<T> {
- const response = await fetch(`${API_BASE}${path}`, { signal, cache: "no-store" });
- if (!response.ok) throw new Error(`可视化后端返回 ${response.status}`);
- return response.json() as Promise<T>;
- }
- export function fetchRuns(signal?: AbortSignal) {
- return getJson<RunSummary[]>("/api/runs", signal);
- }
- export function fetchGraph(scriptBuildId: number, signal?: AbortSignal) {
- return getJson<RunGraph>(`/api/runs/${scriptBuildId}/graph`, signal);
- }
|