feat: 添加container列表

This commit is contained in:
2024-09-17 23:56:47 +08:00
parent 596c50cd0b
commit a36a390d25
16 changed files with 969 additions and 15 deletions

View File

@@ -0,0 +1,63 @@
import { create } from 'zustand';
import { query } from '@/modules';
import { message } from 'antd';
type ContainerStore = {
showEdit: boolean;
setShowEdit: (showEdit: boolean) => void;
formData: any;
setFormData: (formData: any) => void;
loading: boolean;
setLoading: (loading: boolean) => void;
list: any[];
getList: () => Promise<void>;
postData: (data: any) => Promise<void>;
deleteData: (id: string) => Promise<void>;
};
export const useContainerStore = create<ContainerStore>((set, get) => {
return {
showEdit: false,
setShowEdit: (showEdit) => set({ showEdit }),
formData: {},
setFormData: (formData) => set({ formData }),
loading: false,
setLoading: (loading) => set({ loading }),
list: [],
getList: async () => {
const res = await query.post({
path: 'container',
key: 'list',
});
if (res.code === 200) {
set({ list: res.data });
} else {
message.error(res.msg || 'Request failed');
}
},
postData: async (data) => {
const { getList } = get();
const res = await query.post({
path: 'container',
key: 'update',
data,
});
if (res.code === 200) {
getList();
} else {
message.error(res.msg || 'Request failed');
}
},
deleteData: async (id) => {
const { getList } = get();
const res = await query.post({
path: 'container',
key: 'delete',
id,
});
if (res.code === 200) {
getList();
} else {
message.error(res.msg || 'Request failed');
}
},
};
});