feat: 接入后端全局Snippet(导航菜单/站点设置),补充团队/证言/合作伙伴 service 层
- Header 改为异步 Server Component,接入 NavigationMenu(name=main), 接口不可用或未配置时回退静态导航项 - Footer 改为异步 Server Component,接入 SiteSettings, 公司名/ICP备案号/备案链接优先取后台配置,缺省回退硬编码值 - types/wagtail.ts 新增 TeamMember/Testimonial/Partner/NavigationMenu/SiteSettings 类型 - 新增 services: team/testimonial/partner/navigation/site-settings.service.ts - lint、build 均已验证通过
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { fetchAPI } from "./api-client";
|
||||
import type { NavigationMenuValue } from "@/types/wagtail";
|
||||
|
||||
/**
|
||||
* 根据 name(如 main / footer)获取导航菜单(apps.core.NavigationMenu Snippet)。
|
||||
* 未在后台配置对应菜单时返回 null,调用方应回退到静态导航项。
|
||||
*/
|
||||
export async function getNavigationMenu(
|
||||
name: string,
|
||||
): Promise<NavigationMenuValue | null> {
|
||||
try {
|
||||
return await fetchAPI<NavigationMenuValue>(
|
||||
`/api/v1/custom/core/navigation/?name=${encodeURIComponent(name)}`,
|
||||
{ tags: [`navigation:${name}`] },
|
||||
);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user