import { request } from "@cqsjjb/jjb-common-lib/http"; import { useState } from "react"; /** * 删除文件 TODO */ function useDeleteFile() { // loading状态 const [loading, setLoading] = useState(false); // 删除文件 const deleteFile = (options) => { setLoading(true); return new Promise((resolve, reject) => { const { files = [], params = {} } = options; // 构建参数 const actualParams = { id: files.map(file => file.id), ...params, }; // 发送请求 request("", "post", actualParams) .then((res) => { resolve(res.data); }) .catch((err) => { reject(err); }) .finally(() => { setLoading(false); }); }); }; return [loading, deleteFile]; } export default useDeleteFile;