import{Tt as e}from"./vue-vendor-DMUmTARL.js";import{v as t,xt as n}from"./index-BcZTP2Ia.js";function r(r,i,a,o={}){let s=t(),{cacheKey:c,successMessage:l=`保存成功`,afterLoad:u,ready:d}=o,f=e(null),{loading:p,refresh:m}=n(r,{cacheKey:c,ready:d,onSuccess(e){f.value=u?u(e.data):e.data}}),{loading:h,runAsync:g}=n(async e=>i?i(e):Promise.resolve(),{manual:!0,onSuccess(){s.success(l)}});return{configData:f,configLoading:p,reloadConfig:m,saveData:async(e,t)=>{let n=t??f.value;return!n||a?.value&&!await new Promise(t=>{a.value?.validate((n,r)=>{if(n){t(!0);return}if(e===!0&&r)for(let e in r){let t=r[e].map(e=>e.message||``).join(`, `);t&&s.warning(t)}t(!1)})})?!1:(await g(n),!0)},saveLoading:h}}export{r as t};