refactor: 统一模板契约并修复预览版本
This commit is contained in:
1 parent
cd2992c00a
commit
50b87e48de
56 files changed
+7849
-5756
No files matched your search
@@ -7,7 +7,7 @@ const client = createApiClient();
|
||||
|
||||
interface MutationOptions {
|
||||
refresh: () => void;
|
||||
brandConfig: Record<string, unknown> | null | undefined;
|
||||
currentTemplatePackageVersionId: string | null | undefined;
|
||||
onInstallClose: () => void;
|
||||
onPublishClose: () => void;
|
||||
onNoteClear: () => void;
|
||||
@@ -20,11 +20,11 @@ export function usePublicationMutations({
|
||||
onPublishClose,
|
||||
onNoteClear,
|
||||
onRollbackClose,
|
||||
brandConfig,
|
||||
currentTemplatePackageVersionId,
|
||||
}: MutationOptions) {
|
||||
const queryClient = useQueryClient();
|
||||
const install = useMutation({
|
||||
mutationFn: ({ key, versionId }: { key: BrandTemplateKey; versionId?: string }) =>
|
||||
mutationFn: ({ key, versionId }: { key: BrandTemplateKey; versionId: string }) =>
|
||||
client.installAdminTemplate(key, versionId),
|
||||
onSuccess: () => {
|
||||
onInstallClose();
|
||||
@@ -55,12 +55,16 @@ export function usePublicationMutations({
|
||||
},
|
||||
});
|
||||
const selectVisual = useMutation({
|
||||
mutationFn: (key: string) =>
|
||||
client.updateAdminBrand({
|
||||
config: { ...(brandConfig ?? {}), visualTemplateKey: key },
|
||||
mutationFn: (templatePackageVersionId: string) =>
|
||||
client.selectAdminTemplateVersion({
|
||||
templatePackageVersionId,
|
||||
...(currentTemplatePackageVersionId !== undefined
|
||||
? { expectedCurrentPackageVersionId: currentTemplatePackageVersionId }
|
||||
: {}),
|
||||
confirm: true,
|
||||
}),
|
||||
onSuccess: () => {
|
||||
message.success("视觉模板已保存到草稿");
|
||||
message.success("模板版本已切换");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user