feat: 支持视觉模板历史回滚
This commit is contained in:
1 parent
a951504563
commit
a30c939f90
4 files changed
+86
No files matched your search
@@ -50,6 +50,18 @@ export function WorkspacePage() {
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-brand"] });
|
||||
},
|
||||
});
|
||||
const visualHistory = useQuery({
|
||||
queryKey: ["visual-template-history"],
|
||||
queryFn: () => client.getAdminVisualTemplateHistory(),
|
||||
});
|
||||
const rollbackVisual = useMutation({
|
||||
mutationFn: () => client.rollbackAdminVisualTemplate(),
|
||||
onSuccess: () => {
|
||||
message.success("视觉模板已回滚");
|
||||
void runtimeQuery.refetch();
|
||||
void visualHistory.refetch();
|
||||
},
|
||||
});
|
||||
const install = useMutation({
|
||||
mutationFn: (key: "personal" | "food") => client.installAdminTemplate(key),
|
||||
onSuccess: () => {
|
||||
@@ -188,6 +200,29 @@ export function WorkspacePage() {
|
||||
)}
|
||||
</Space>
|
||||
<MutationError error={visualTemplate.error} />
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<Typography.Text strong>视觉模板切换历史</Typography.Text>
|
||||
{visualHistory.data?.history.length ? (
|
||||
visualHistory.data.history.map((item) => (
|
||||
<Tag key={`${item.visualTemplateKey}-${item.savedAt}`}>
|
||||
{item.visualTemplateKey} · {item.savedAt}
|
||||
</Tag>
|
||||
))
|
||||
) : (
|
||||
<Typography.Text type="secondary">暂无历史版本</Typography.Text>
|
||||
)}
|
||||
{visualHistory.data?.history.length ? (
|
||||
<Button
|
||||
danger
|
||||
size="small"
|
||||
onClick={() => rollbackVisual.mutate()}
|
||||
loading={rollbackVisual.isPending}
|
||||
>
|
||||
回滚上一版视觉模板
|
||||
</Button>
|
||||
) : null}
|
||||
<MutationError error={rollbackVisual.error} />
|
||||
</Space>
|
||||
<Modal
|
||||
title="确认切换视觉模板"
|
||||
open={visualTarget !== null}
|
||||
|
||||
Reference in new issue
Block a user