import{_ as h,i as U,r as m,q as P,$ as G,s as R,c as _,d as g,h as b,f as i,e as c,w as p,t as d,j as y,F as V,bt as q,bu as M,K as T,bv as z}from"./index-BV0H45HW.js";import"./index-BtHEBb5f.js";import{B as D}from"./index-CBHeC2k-.js";import{C as $}from"./index-Dvq70EEv.js";const j={key:0,class:"wrapper"},A={class:"circle-text"},E={class:"line2"},K={class:"text"},H={key:1,class:"wrapper"},J={class:"circle-text"},L={class:"line2"},O={class:"text"},Q={key:2,class:"wrapper-cleaning"},W=["src"],X={__name:"index",setup(Y){U.global.t;const v=m(0),x={"25.93%":"#42C652","68.43%":"#FFD412","82.74%":"#FF6912"},C={"0%":"#46A2FF","100%":"#12F3FF"},e=P({useSpace:0,originUseSpace:0,totalSpace:0,releasedSpace:0,status:"idle",process:0,spaceRate:0}),t=m(null),r=m(null),u=m(0),F=async()=>{t.value&&(clearInterval(t.value),t.value=null);try{e.originUseSpace=e.useSpace;const{code:s,data:a}=await z();if(s===200){if(e.status=a==null?void 0:a.status,e.status!=="running")return}else{e.status="failed";return}t.value=setInterval(()=>{I()},2e3)}catch(s){console.error("清理接口调用失败",s),e.status="failed",clearInterval(t.value)}},S=s=>{const a=Number(s);return isNaN(a)||a<0?0:(a/1024).toFixed(1)},w=(s,a)=>{if(a<=0){e.process=0,clearInterval(r.value);return}switch(s){case"cleaning":clearInterval(r.value),u.value=e.process||0,r.value=setInterval(()=>{const n=Math.random()*2+1;u.value+=n,u.value>=98&&(u.value=98),e.process=Number(u.value.toFixed(1))},500);break;case"success":clearInterval(r.value),e.process=100;break;case"idle":case"failed":clearInterval(r.value),e.process=0,u.value=0;break;default:e.process=0;break}},I=async(s=!0)=>{try{const a=[q().catch(l=>({err:l,code:-1}))];s&&a.push(M().catch(l=>({err:l,code:-1})));const[n,o]=await Promise.all(a);if(n.code===200){const{total_space:l,used_space:k,releaseable_space:N}=n==null?void 0:n.data;e.totalSpace=S(l),e.useSpace=S(k),e.releasedSpace=N,e.spaceRate=Math.round(e.useSpace/e.totalSpace*100)}if(s&&o&&o.code===200){const{status:l}=o==null?void 0:o.data;e.status=l,["success","failed","idle"].includes(e.status)&&(clearInterval(t.value),t.value=null,clearInterval(r.value),r.value=null),w(l,e.releasedSpace)}}catch(a){console.error(a),t.value&&(clearInterval(t.value),clearInterval(r.value),t.value=null,r.value=null,e.status="failed",e.process=0)}};let f;G(()=>e.status,s=>{s=="success"&&(f=T({type:"success",message:` 磁盘空间清理完成,已释放${S(e.originUseSpace-e.useSpace)}GB 空间`,className:"bottom-notify",position:"bottom"}))}),I(!1);const B=()=>{e.status="idle"};return R(()=>{f==null||f.close(),t.value&&clearInterval(t.value),r.value&&clearInterval(r.value)}),(s,a)=>{const n=$,o=D;return g(),_(V,null,[e.status==="idle"||e.status==="success"?(g(),_("div",j,[i(n,{"current-rate":v.value,"onUpdate:currentRate":a[0]||(a[0]=l=>v.value=l),rate:e.spaceRate,speed:100,size:"150px",color:x},{default:p(()=>[c("div",A,[a[2]||(a[2]=c("span",{class:"line1"},"磁盘使用状态",-1)),c("span",E,d(e.useSpace)+"/"+d(e.totalSpace)+"GB ",1)])]),_:1},8,["current-rate","rate"]),c("div",K,"预计可释放"+d(e.releasedSpace)+"空间",1),i(o,{round:"",type:"primary",class:"clear-btn",onClick:F},{default:p(()=>a[3]||(a[3]=[y(" 一键清理 ")])),_:1,__:[3]})])):b("",!0),e.status==="running"?(g(),_("div",H,[i(n,{"current-rate":v.value,"onUpdate:currentRate":a[1]||(a[1]=l=>v.value=l),rate:e.process,speed:100,size:"150px",color:C},{default:p(()=>[c("div",J,[a[4]||(a[4]=c("span",{class:"line1"},"磁盘清理中",-1)),c("span",L,d(e.process)+"%",1)])]),_:1},8,["current-rate","rate"]),c("div",O,"预计可释放"+d(e.releasedSpace)+"空间",1),i(o,{round:"",type:"primary",class:"clear-btn",disabled:""},{default:p(()=>a[5]||(a[5]=[y(" 一键清理 ")])),_:1,__:[5]})])):b("",!0),e.status==="failed"?(g(),_("div",Q,[c("img",{src:s.loadingImg,class:"loading-img",alt:""},null,8,W),a[7]||(a[7]=c("p",null,"服务器异常，请返回重试...",-1)),i(o,{round:"",type:"primary",class:"back-btn",onClick:B},{default:p(()=>a[6]||(a[6]=[y(" 返回 ")])),_:1,__:[6]})])):b("",!0)],64)}}},te=h(X,[["__scopeId","data-v-ce9f5103"]]);export{te as default};
