import{request as e}from"@cqsjjb/jjb-common-lib/http.js";import{useState as i}from"react";function l(l="object"){const[t,r]=i(!1);let o=0;const s=i=>{if(i)return o++,o>0&&r(!0),new Promise((l,t)=>{const{files:s=[],single:n=!0}=i;if(s)if(Array.isArray(s)){if(0===s.length)return o--,o<=0&&r(!1),void l();if(n){if(!s[0].filePath)return o--,o<=0&&r(!1),void l()}else if(0===s.filter(e=>e.id).length)return o--,o<=0&&r(!1),void l();e(n?`/basicInfo/imgFiles/delete?filePath=${s[0].filePath}`:`/basicInfo/imgFiles/ids?ids=${s.filter(e=>e.id).map(e=>e.id)}`,"delete").then(e=>{l(e.data)}).catch(e=>{t(e)}).finally(()=>{o--,o<=0&&r(!1)})}else console.error("【deleteFile】 的 files 需要是一个数组");else console.error("【deleteFile】 缺少 files 参数")});console.error("【deleteFile】 缺少 options 参数")};return"array"===l?[t,s]:{loading:t,deleteFile:s}}export{l as default};
