import{_ as h,i as m,u as T,a as I,b9 as S,q as b,r as U,o as q,s as x,c,d,e as t,F as k,y as A,t as _,f as L,j as N,g as P,bd as B}from"./index-CGyEz3rP.js";import{P as V}from"./index-B4WkqIIG.js";import{i as C}from"./info-Bq3qLitc.js";const D={class:"version-download-wrapper"},F={class:"app-list-container"},R={class:"top"},j={class:"title"},z={class:"info"},E={class:"bottom"},G={class:"bottom-message"},H=["src"],M={__name:"version-download",setup(J){m.global.t;const l=T(),i=I(),p=i.query.isUpdateAll==="true",f=S(),o=b({systemType:"",appLists:[]}),a=U(null),g=e=>e?e==="failure"?"failed":e==="success"?"success":e==="extracting"?"extracting":e==="downloading"?"downloading":"pending":"pending",v=async()=>{try{const e=await B({taskId:f.updateTaskId});if((e==null?void 0:e.code)===200&&e.data){const r=e.data;o.systemType=i.query.systemType||r.systemType||o.systemType;const{stage:n,status:s,moduleList:y}=r;return n!=="download_update"?(a.value&&(clearInterval(a.value),a.value=null),n==="install_update"?l.replace({name:"versionInstall",query:{systemType:o.systemType,isUpdateAll:p}}).catch(()=>{}):n==="system_update"&&l.replace({name:"toolsUpgrade",query:{status:"success"}}).catch(()=>{}),!1):s==="failure"?(a.value&&(clearInterval(a.value),a.value=null,f.clearUpdateTaskId()),l.push({name:"toolsUpgrade",query:{status:"failed"}}).catch(()=>{}),!1):s==="success"?(a.value&&(clearInterval(a.value),a.value=null),l.replace({name:"versionInstall",query:{systemType:o.systemType,isUpdateAll:p}}).catch(()=>{}),!1):(Array.isArray(y)&&(o.appLists=y.map((u,w)=>({name:u.name,id:w,downloadStatus:g(u.status),downloadProgress:u.progress?Number(u.progress):0}))),!0)}else console.error("getUpdateStatus 返回异常",e)}catch(e){console.error("获取更新状态异常",e)}return!0};return q(async()=>{await v()&&!a.value&&(a.value=setInterval(v,2e3))}),x(()=>{a.value&&(clearInterval(a.value),a.value=null)}),(e,r)=>{const n=V;return d(),c("div",D,[t("ul",F,[(d(!0),c(k,null,A(o.appLists,s=>(d(),c("li",{key:s.id},[t("div",R,[t("div",j,_(s.name),1),t("div",z,_((s==null?void 0:s.downloadStatus)==="downloading"||(s==null?void 0:s.downloadStatus)==="extracting"?"下载中":(s==null?void 0:s.downloadStatus)==="success"?"下载完成":(s==null?void 0:s.downloadStatus)==="failed"?"下载失败":"等待"),1)]),t("div",E,[L(n,{class:"custom-progress",percentage:s.downloadProgress||0},null,8,["percentage"])])]))),128))]),t("div",G,[t("img",{src:P(C),alt:""},null,8,H),r[0]||(r[0]=N(" 为了避免中断，请勿关闭或刷新页面 "))])])}}},W=h(M,[["__scopeId","data-v-cd28d8ed"]]);export{W as default};
