chore: sync marketing pages, CMS extensions, tests and project docs
同步工作区剩余变更,主要包括: - 营销页面组件与布局持续优化(about/news/services/solutions/team 等) - 详情页四层叙事组件、布局组件、UI 组件调整 - CMS 数据模型、API 路由、权限、工作流、站内通知、媒体管理扩展 - 新增/补充单元测试与 E2E 测试(cms-workflow.spec.ts 等) - ESLint 9 迁移、jest/tsconfig 配置更新、依赖调整 - 新增 ADR、CMS 评估文档、Release Review / Acceptance 报告 - 移除水墨装饰组件与大体积未使用字体文件
This commit is contained in:
@@ -15,6 +15,7 @@ function toContentItem(item: Record<string, unknown>): ContentItem {
|
||||
modelCode: item.modelCode as string,
|
||||
title: item.title as string,
|
||||
slug: (item.slug as string | null) ?? undefined,
|
||||
locale: (item.locale as string | null) ?? 'zh-CN',
|
||||
status: item.status as ContentStatus,
|
||||
data: JSON.parse(item.data as string),
|
||||
version: item.version as number,
|
||||
@@ -160,6 +161,40 @@ export async function getHomePageZones() {
|
||||
return getPageZones('home');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页各 Zone 并解析引用的已发布内容条目
|
||||
* 返回以 zoneKey 为键的内容条目数组映射
|
||||
*/
|
||||
export async function getResolvedHomeZones(): Promise<Record<string, ContentItem[]>> {
|
||||
const zones = await getHomePageZones();
|
||||
const result: Record<string, ContentItem[]> = {};
|
||||
|
||||
if (zones.length === 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const itemIds = zones
|
||||
.flatMap((z) => z.items.map((i: { itemId?: string }) => i.itemId).filter(Boolean));
|
||||
|
||||
if (itemIds.length > 0) {
|
||||
const items = await prisma.contentItem.findMany({
|
||||
where: { id: { in: itemIds as string[] }, status: 'published' },
|
||||
});
|
||||
const itemMap = new Map(
|
||||
items.map((item) => [item.id, toContentItem(item as unknown as Record<string, unknown>)]),
|
||||
);
|
||||
|
||||
for (const zone of zones) {
|
||||
const key = zone.zoneKey || zone.code;
|
||||
result[key] = zone.items
|
||||
.map((zi: { itemId?: string }) => (zi.itemId ? itemMap.get(zi.itemId) : undefined))
|
||||
.filter(Boolean) as ContentItem[];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ============ 静态生成辅助 ============
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user