fix: 校验必需信任内容完整性

This commit is contained in:
que01 committed 2026-09-27 14:37:07 +08:00
1 parent 5ed06b1abe
commit 0c5ff79b42
4 files changed
+71 -10

No files matched your search

+8 -5
View File
@@ -80,9 +80,12 @@ export class BrandReleaseApiService {
}),
database.trustContent.findMany({
where: { brandId, isPublished: true },
select: { type: true },
select: { type: true, title: true, content: true },
}),
]);
const validTrustItems = trustItems.filter(
(item) => item.title.trim().length > 0 && item.content.trim().length > 0,
);
const offeringIds = new Set(offerings.map((item) => item.id));
const usableForms = forms.filter(
(form) =>
@@ -132,18 +135,18 @@ export class BrandReleaseApiService {
{
key: "trust",
label: "至少需要一条已发布的信任内容",
passed: trustItems.length > 0,
passed: validTrustItems.length > 0,
destination: "/admin/trust",
},
];
const publishedTrustTypes = new Set(trustItems.map((item) => item.type));
const publishedTrustTypes = new Set(validTrustItems.map((item) => item.type));
for (const type of packageManifest?.trustContentTypes ?? []) {
if (type.required !== true) continue;
checks.push({
key: `trust:${type.type}`,
label: `请补充${type.label}`,
label: `请完善${type.label}`,
passed: publishedTrustTypes.has(type.type),
...(type.help ? { help: type.help } : {}),
help: ["标题和详细内容都填写后才能发布。", type.help].filter(Boolean).join(" "),
destination: "/admin/trust",
});
}