feat: 分离模板演示数据并校验预览资源

This commit is contained in:
que01 committed 2026-10-16 17:55:52 +08:00
1 parent 6edde5a8d6
commit b60174885e
31 files changed
+1785 -69

No files matched your search

@@ -1,6 +1,6 @@
import { useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { Alert, Modal, Select, Typography } from "antd";
import { Alert, Collapse, List, Modal, Select, Tag, Typography } from "antd";
import type { TemplatePackageVersion } from "@personal-brand/api-client";
import { createApiClient } from "../../lib/api.js";
import { QueryState } from "../../components/QueryState.js";
@@ -76,6 +76,20 @@ export function TemplatePackagePreviewModal({
>
{data ? (
<>
{data.preview.diagnostics.map((diagnostic) => (
<Alert
key={diagnostic.code}
type="warning"
showIcon
message={diagnostic.message}
/>
))}
<Typography.Text type="secondary">
演示数据:
{data.preview.fixtureSource === "previewFixture"
? "独立预览内容"
: "兼容起始内容"}
</Typography.Text>
<Typography.Paragraph type="secondary">
{data.industry.name} · Runtime {data.compatibility.runtimeContract} · renderer{" "}
{data.compatibility.renderer.key}@{data.compatibility.renderer.version}
@@ -103,9 +117,65 @@ export function TemplatePackagePreviewModal({
onChange={setOfferingId}
/>
) : null}
<Collapse
items={[
{
key: "modules",
label: "页面模块与字段来源",
children: (
<List
dataSource={
data.preview.pages.find((item) => item.key === page)?.modules ?? []
}
locale={{ emptyText: "此页面由 Runtime 提供,不包含模板编辑模块" }}
renderItem={(item) => (
<List.Item>
<div>
<Typography.Text strong>{item.title}</Typography.Text>
<Typography.Paragraph type="secondary">
{item.bindings.join("、")}
</Typography.Paragraph>
</div>
</List.Item>
)}
/>
),
},
{
key: "assets",
label: "资源诊断",
children: (
<List
dataSource={data.preview.assets}
locale={{ emptyText: "模板未声明资源槽位" }}
renderItem={(item) => (
<List.Item>
<div>
{item.label}{" "}
<Tag color={item.status === "missing" ? "warning" : "default"}>
{item.status === "missing"
? "内容缺失"
: item.status === "ready"
? "包内资源已验证"
: "可用性待验证"}
</Tag>
{item.required ? "必需" : "可选"} · 已配置 {item.populated}/
{item.total}
<Typography.Paragraph type="secondary">
{item.binding}
</Typography.Paragraph>
</div>
</List.Item>
)}
/>
),
},
]}
/>
<ComponentTemplatePreview
key={`${version.id}:${industry}:${page}`}
workspace={data.workspace}
assetFiles={data.preview.assetFiles}
page={page}
{...((offeringId ?? data.workspace.offerings[0]?.id)
? { offeringId: offeringId ?? data.workspace.offerings[0]!.id }