feat: 暂存, 添加ui2
This commit is contained in:
@@ -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={() => {
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user