- types: SolutionPageSummary/Detail - services/solution.service.ts - app/solutions: list + detail pages - Header nav: add 解决方案 link
27 lines
875 B
TypeScript
27 lines
875 B
TypeScript
import { fetchAPI } from "./api-client";
|
|
import type {
|
|
SolutionPageDetail,
|
|
SolutionPageSummary,
|
|
WagtailListResponse,
|
|
} from "@/types/wagtail";
|
|
|
|
/** 获取解决方案列表。 */
|
|
export async function getSolutionList(): Promise<SolutionPageSummary[]> {
|
|
const res = await fetchAPI<WagtailListResponse<SolutionPageSummary>>(
|
|
"/api/v2/pages/?type=solutions.SolutionPage&fields=industry,summary",
|
|
{ tags: ["solution-list"] },
|
|
);
|
|
return res.items;
|
|
}
|
|
|
|
/** 根据 slug 获取解决方案详情。 */
|
|
export async function getSolutionBySlug(
|
|
slug: string,
|
|
): Promise<SolutionPageDetail | null> {
|
|
const res = await fetchAPI<WagtailListResponse<SolutionPageDetail>>(
|
|
`/api/v2/pages/?type=solutions.SolutionPage&slug=${encodeURIComponent(slug)}&fields=body,industry,summary&limit=1`,
|
|
{ tags: [`solution:${slug}`] },
|
|
);
|
|
return res.items[0] ?? null;
|
|
}
|