feat: 暂存, 添加ui2

This commit is contained in:
2024-09-21 22:58:46 +08:00
parent 052dd919cd
commit 4d308921a3
14 changed files with 609 additions and 236 deletions

View File

@@ -84,6 +84,7 @@ export const ContainerList = () => {
deleteData: state.deleteData,
getList: state.getList,
loading: state.loading,
publishData: state.publishData,
};
}),
);
@@ -145,6 +146,12 @@ export const ContainerList = () => {
}}>
Preview
</Button>
<Button
onClick={() => {
containerStore.publishData(record);
}}>
Publish
</Button>
<Button
danger
onClick={() => {

View File

@@ -12,6 +12,7 @@ type ContainerStore = {
getList: () => Promise<void>;
updateData: (data: any) => Promise<void>;
deleteData: (id: string) => Promise<void>;
publishData: (data: any) => Promise<void>;
};
export const useContainerStore = create<ContainerStore>((set, get) => {
return {
@@ -65,5 +66,29 @@ export const useContainerStore = create<ContainerStore>((set, get) => {
message.error(res.msg || 'Request failed');
}
},
publishData: async (data) => {
const hasPublish = !!data.publish?.name;
const publish = {
name: 'test-import',
};
if (!hasPublish) {
console.error('need publish.name');
return;
}
const res = await query.post({
path: 'container',
key: 'publish',
data: {
id: data.id,
publish: publish,
type: 'patch',
},
});
if (res.code === 200) {
message.success('Success');
} else {
message.error(res.msg || 'Request failed');
}
},
};
});