import{_ as I,i as S,u as b,a as x,b9 as A,q,r as P,o as L,s as k,c as u,d as i,e as r,F as D,y as N,t as p,f as C,j as O,g as m,bd as B}from"./index-ojdwC1S2.js";import{P as F}from"./index-CQ4vOoEb.js";import{i as R}from"./info-Bq3qLitc.js";const V={class:"version-download-wrapper"},E={class:"app-list-container"},M={class:"top"},j={class:"title"},z={class:"info"},G={class:"bottom"},H={class:"bottom-message"},W=["src"],X={__name:"version-download",setup(J){const t=S.global.t,c=b(),g=x(),_=g.query.isUpdateAll==="true",y=A(),n=q({systemType:"",appLists:[]}),s=P(null),h=e=>e?e==="failure"?"failed":e==="success"?"success":e==="extracting"?"extracting":e==="downloading"?"downloading":"pending":"pending",w={pending:t("toolsUpgrade.pending"),downloading:t("toolsUpgrade.downloading"),extracting:t("toolsUpgrade.downloading"),success:t("toolsUpgrade.downloadComplete"),failed:t("toolsUpgrade.downloadFailed")},T=e=>w[e]||t("toolsUpgrade.pending"),f=async()=>{try{const e=await B();if((e==null?void 0:e.code)===200&&e.data){const l=e.data;n.systemType=g.query.systemType||l.systemType||n.systemType;const{stage:a,status:o,moduleList:v}=(l==null?void 0:l.install_status)||{};return a?a!=="download_update"&&a!=="pre_check"?(s.value&&(clearInterval(s.value),s.value=null),a==="install_update"?c.replace({name:"versionInstall",query:{systemType:n.systemType,isUpdateAll:_}}).catch(()=>{}):a==="system_update"&&c.replace({name:"toolsUpgrade",query:{status:"success"}}).catch(()=>{}),!1):o==="failure"?(s.value&&(clearInterval(s.value),s.value=null,y.clearUpdateTaskId()),c.push({name:"toolsUpgrade",query:{status:"failed"}}).catch(()=>{}),!1):o==="success"?(s.value&&(clearInterval(s.value),s.value=null),c.replace({name:"versionInstall",query:{systemType:n.systemType,isUpdateAll:_}}).catch(()=>{}),!1):(Array.isArray(v)&&(n.appLists=v.map((d,U)=>({name:d.name,id:U,downloadStatus:h(d.status),downloadProgress:d.progress?Number(d.progress):0}))),!0):!0}else console.error("getOverallUpdateProgress 返回异常",e)}catch(e){console.error("获取更新状态异常",e)}return!0};return L(async()=>{await f()&&!s.value&&(s.value=setInterval(f,2e3))}),k(()=>{s.value&&(clearInterval(s.value),s.value=null)}),(e,l)=>{const a=F;return i(),u("div",V,[r("ul",E,[(i(!0),u(D,null,N(n.appLists,o=>(i(),u("li",{key:o.id},[r("div",M,[r("div",j,p(o.name),1),r("div",z,p(T(o.downloadStatus)),1)]),r("div",G,[C(a,{class:"custom-progress",percentage:o.downloadProgress||0},null,8,["percentage"])])]))),128))]),r("div",H,[r("img",{src:m(R),alt:""},null,8,W),O(" "+p(m(t)("toolsUpgrade.avoidCloseRefresh")),1)])])}}},Z=I(X,[["__scopeId","data-v-514c330e"]]);export{Z as default};
