test: 暂存

This commit is contained in:
2024-09-18 04:17:11 +08:00
parent a36a390d25
commit b838488776
19 changed files with 683 additions and 142 deletions

View File

@@ -10,7 +10,7 @@ type ContainerStore = {
setLoading: (loading: boolean) => void;
list: any[];
getList: () => Promise<void>;
postData: (data: any) => Promise<void>;
updateData: (data: any) => Promise<void>;
deleteData: (id: string) => Promise<void>;
};
export const useContainerStore = create<ContainerStore>((set, get) => {
@@ -23,17 +23,20 @@ export const useContainerStore = create<ContainerStore>((set, get) => {
setLoading: (loading) => set({ loading }),
list: [],
getList: async () => {
set({ loading: true });
const res = await query.post({
path: 'container',
key: 'list',
});
set({ loading: false });
if (res.code === 200) {
set({ list: res.data });
} else {
message.error(res.msg || 'Request failed');
}
},
postData: async (data) => {
updateData: async (data) => {
const { getList } = get();
const res = await query.post({
path: 'container',
@@ -41,6 +44,8 @@ export const useContainerStore = create<ContainerStore>((set, get) => {
data,
});
if (res.code === 200) {
message.success('Success');
set({ showEdit: false, formData: [] });
getList();
} else {
message.error(res.msg || 'Request failed');
@@ -55,6 +60,7 @@ export const useContainerStore = create<ContainerStore>((set, get) => {
});
if (res.code === 200) {
getList();
message.success('Success');
} else {
message.error(res.msg || 'Request failed');
}