feat: 接入模板升级管理界面

This commit is contained in:
que01 committed 2026-09-20 17:58:52 +08:00
1 parent 44b6f6db64
commit 74feb3579c
1 file changed
+42
@@ -60,6 +60,19 @@ export function WorkspacePage() {
queryKey: ["admin-inquiry-forms"],
queryFn: () => client.listAdminInquiryForms(),
});
const templatePreview = useQuery({
queryKey: ["admin-template-preview"],
queryFn: () => client.getAdminTemplateUpgradePreview(),
enabled: Boolean(query.data?.installations?.length),
});
const upgrade = useMutation({
mutationFn: () => client.upgradeAdminTemplate(),
onSuccess: () => {
message.success("模板已升级,已有内容未被覆盖");
void queryClient.invalidateQueries({ queryKey: ["admin-workspace"] });
void queryClient.invalidateQueries({ queryKey: ["admin-template-preview"] });
},
});
const createForm = useMutation({
mutationFn: (values: { name: string; fieldsSnapshot: unknown[] }) =>
client.createAdminInquiryForm(values),
@@ -125,6 +138,35 @@ export function WorkspacePage() {
模板只提供行业表达样例,不会替代你的品牌定位、经历、作品和合作方式。
</Typography.Paragraph>
<Tag>{installations.length ? `已安装 ${installations.length} 个模板` : "尚未安装模板"}</Tag>
{installations.length > 0 && (
<Card size="small" style={{ marginTop: 16 }} title="模板版本">
<Space direction="vertical" style={{ width: "100%" }}>
<Typography.Text>
当前版本:{templatePreview.data?.currentVersion ?? "加载中"},最新版本:
{templatePreview.data?.latestVersion ?? "加载中"}
</Typography.Text>
{templatePreview.data?.canUpgrade ? (
<>
<Typography.Paragraph type="secondary" style={{ marginBottom: 0 }}>
可升级内容:新增 {templatePreview.data.missingModules.length} 个模块,新增{" "}
{templatePreview.data.missingFields.length} 个字段。已有内容不会被覆盖。
</Typography.Paragraph>
<Button
type="primary"
onClick={() => upgrade.mutate()}
loading={upgrade.isPending}
>
确认升级模板
</Button>
</>
) : (
<Tag color="green">已是最新版本</Tag>
)}
<MutationError error={templatePreview.error} />
<MutationError error={upgrade.error} />
</Space>
</Card>
)}
<MutationError error={install.error} />
</Card>
<Card