feat: add solutions list/detail pages
- types: SolutionPageSummary/Detail - services/solution.service.ts - app/solutions: list + detail pages - Header nav: add 解决方案 link
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user