import { serverApiBase } from "./config"; import type { ForeshadowBoardResponse, ProjectListResponse, ProjectResponse, ProvidersResponse, ReviewHistoryResponse, } from "./types"; // 服务端只读取数据(Server Components)。失败时抛出,由页面边界处理。 async function getJson(path: string): Promise { const res = await fetch(`${serverApiBase()}${path}`, { cache: "no-store" }); if (!res.ok) { throw new Error(`请求失败 ${res.status}: ${path}`); } return (await res.json()) as T; } export async function fetchProjects(): Promise { return getJson("/projects"); } export async function fetchProject(projectId: string): Promise { return getJson(`/projects/${projectId}`); } export async function fetchProviders(): Promise { return getJson("/settings/providers"); } export async function fetchReviews( projectId: string, chapterNo: number, ): Promise { return getJson( `/projects/${projectId}/chapters/${chapterNo}/reviews`, ); } // 伏笔看板(全量,前端按 status 分四泳道)。 export async function fetchForeshadow( projectId: string, ): Promise { return getJson(`/projects/${projectId}/foreshadow`); }