2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
import{a3 as T,d as ae,r as h,s as se,a1 as K,h as n,I as q,w as l,y as L,c,e,a as t,t as o,u as i,N as a,F as R,G as A,B as F,z as M,af as ne,ag as J,a8 as oe,an as ue,ao as ce,a2 as re,ap as ie,aq as de,aa as pe,a0 as xe,_ as _e,i as S,a4 as Z,ar as ke,E as ye,p as be,g as we}from"./index-4dcc0234.js";/* empty css */import{T as fe,_ as ve}from"./vue-web-terminal-6f196033.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */function Ce(g=""){return T.get(g?`upgrade/${g}`:"upgrade")}function Be(){return T.get("upgrade/task")}function Te(g=""){return T.post(g?`upgrade/${g}`:"upgrade")}function Ee(){return T.post("upgrade/execute")}function $e(g=""){return T.get(g?`upgrade/check/${g}`:"upgrade/check")}function Ie(){return T.post("upgrade/clear")}function Ue(){return T.post("niucloud/build")}function Se(){return T.get("niucloud/build")}function Ve(){return T.get("niucloud/build/log")}function Fe(){return T.post("niucloud/build/clear")}function Le(){return T.get("niucloud/build/check")}const Me={class:"h-[60vh]"},Ne={key:0,class:"h-[60vh] flex flex-col"},Re={key:0,class:"bg-[#fff] my-3"},De={class:"pt-[20px] pl-[20px]"},He={class:"px-[20px] pt-[10px] text-[14px] el-table"},je={key:0},qe={key:1},Ae={key:0},Pe={key:1},ze={class:"h-[60vh]"},Ge={class:"h-[60vh] flex flex-col"},Ke={class:"flex-1 h-0"},Je=ae({__name:"index",emits:["complete"],setup(g,{expose:O,emit:ee}){const r=h(!1),d=h(null),p=h("build"),m=h(null),w=h(!1),b=h(null);let C=[];(()=>{Se().then(({data:_})=>{_&&(d.value=_,r.value||W())}).catch()})();const $=()=>{Ve().then(_=>{if(!_.data){r.value&&C.length&&(p.value="complete",b.value.execute("clear")),I&&I.close(),d.value=null;return}const f=_.data.data??[];let v="";f[0]&&f[0].length&&r.value&&(C.length==0&&(b.value.execute("clear"),b.value.execute("开始编译")),f[0].forEach(x=>{C.includes(x.action)||(b.value.pushMessage({content:`正在执行:${x.action}`}),C.push(x.action),x.code==0&&(v=x.msg,b.value.pushMessage({content:x.msg,class:"error"})))})),!v&&setTimeout(()=>{$()},2e3)}).catch()};let I=null;const W=()=>{I=ne.success({title:a("warning"),dangerouslyUseHTMLString:!0,message:J("div",{},[a("cloudbuild.executingTips"),J("span",{class:"text-primary cursor-pointer",onClick:V},[a("cloudbuild.clickView")])]),duration:0,showClose:!1})},V=()=>{r.value=!0,p.value="build",$()},X=async()=>{if(r.value=!0,w.value=!0,p.value="build",d.value){w.value=!1,$();return}Le().then(async({data:_})=>{_.is_pass?Ue().then(({data:f})=>{w.value=!1,d.value=f,$()}).catch(()=>{r.value=!1}):(w.value=!1,m.value=_)}).catch(()=>{r.value=!1})};let D=null;const P=new fe,Y=(_,f,v,x,j)=>{if(f=="开始编译"){v(P);const s=H(["/","——","\\","|"]);D=setInterval(()=>{P.flush("> "+s.next().value)},150)}},H=_=>{var f=0;return{next(){return f+1==_.length&&(f=0),{value:_[f++]}}}},z=_=>{p.value=="cloudbuild"&&d.value?oe.confirm(a("cloudbuild.showDialogCloseTips"),a("warning"),{confirmButtonText:a("confirm"),cancelButtonText:a("cancel"),type:"warning"}).then(()=>{_()}).catch(()=>{}):_()};return se(()=>r.value,()=>{r.value||(C=[],D&&clearInterval(D),Fe())}),O({open:X,cloudBuildTask:d}),(_,f)=>{const v=ue,x=ce,j=K("Select"),s=re,u=K("CloseBold"),E=ie,U=de,N=pe,k=xe;return n(),q(N,{modelValue:r.value,"onUpdate:modelValue":f[0]||(f[0]=B=>r.value=B),title:i(a)("cloudbuild.title"),width:"850px","close-on-click-modal":!1,"close-on-press-escape":!1,"before-close":z},{default:l(()=>[L((n(),c("div",Me,[m.value&&!d.value?(n(),c("div",Ne,[e(E,null,{default:l(()=>[m.value.dir?(n(),c("div",Re,[t("p",De,o(i(a)("cloudbuild.dirPermission")),1),t("div",He,[e(x,{class:"py-[10px] items table-head-bg pl-[15px] mb-[10px]"},{default:l(()=>[e(v,{span:12},{default:l(()=>[t("span",null,o(i(a)("cloudbuild.path")),1)]),_:1}),e(v,{span:6},{default:l(()=>[t("span",null,o(i(a)("cloudbuild.demand")),1)]),_:1}),e(v,{span:6},{default:l(()=>[t("span",null,o(i(a)("status")),1)]),_:1})]),_:1}),(n(!0),c(R,null,A(m.value.dir.is_readable,B=>(n(),q(x,{class:"pb-[10px] items pl-[15px]"},{default:l(()=>[e(v,{span:12},{default:l(()=>[t("span",null,o(B.dir),1)]),_:2},1024),e(v,{span:6},{default:l(()=>[t("span",null,o(i(a)("cloudbuild.readable")),1)]),_:1}),e(v,{span:6},{default:l(()=>[B.status?(n(),c("span",je,[e(s,{color:"green"},{default:l(()=>[e(j)]),_:1})])):(n(),c("span",qe,[e(s,{color:"red"},{default:l(()=>[e(u)]),_:1})]))]),_:2},1024)]),_:2},1024))),256)),(n(!0),c(R,null,A(m.value.dir.is_write,B=>(n(),q(x,{class:"pb-[10px] items pl-[15px]"},{default:l(()=>[e(v,{span:12},{default:l(()=>[t("span",null,o(B.dir),1)]),_:2},1024),e(v,{span:6},{default:l(()=>[t("span",null,o(i(a)("cloudbuild.write")),1)]),_:1}),e(v,{span:6},{default:l(()=>[B.status?(n(),c("span",Ae,[e(s,{color:"green"},{default:l(()=>[e(j)]),_:1})])):(n(),c("span",Pe,[e(s,{color:"red"},{default:l(()=>[e(u)]),_:1})]))]),_:2},1024)]),_:2},1024))),256))])])):F("",!0)]),_:1})])):F("",!0),L(t("div",ze,[e(i(ve),{ref_key:"terminalRef",ref:b,context:"","init-log":null,"show-header":!1,"show-log-time":!0,onExecCmd:Y},null,512)],512),[[M,d.value]])])),[[M,p.value=="build"],[k,w.value]]),L(t("div",null,[t("div",Ge,[t("div",Ke,[e(U,{icon:"success",title:i(a)("cloudbuild.cloudbuildSuccess")},null,8,["title"])])])],512),[[M,p.value=="complete"]])]),_:1},8,["modelValue","title"])}}});const Oe=_e(Je,[["__scopeId","data-v-b4dec182"]]),Qe=g=>(be("data-v-dd711ee6"),g=g(),we(),g),We={key:0,class:"h-[60vh] flex flex-col"},Xe={class:"text-lg"},Ye={class:"font-bold"},Ze={class:"font-bold"},el={key:0,class:"mt-[10px]"},ll=Qe(()=>t("a",{class:"text-primary",href:"https://www.niucloud.com",target:"_blank"},"niucloud-admin官网",-1)),tl={class:"font-bold text-lg"},al={class:"mt-[5px]"},sl=["innerHTML"],nl={class:"flex justify-end"},ol={key:0,class:"h-[60vh] flex flex-col"},ul={key:0,class:"bg-[#fff] my-3"},cl={class:"pt-[20px] pl-[20px]"},rl={class:"px-[20px] pt-[10px] text-[14px] el-table"},il={key:0},dl={key:1},pl={key:0},_l={key:1},fl={class:"h-[60vh]"},vl={class:"h-[60vh] flex flex-col"},gl={class:"flex-1 h-0"},hl={class:"flex justify-end"},ml=ae({__name:"index",emits:["complete"],setup(g,{expose:O,emit:ee}){const r=h(!1),d=h(null),p=h(null),m=h("content"),w=h(null),b=h(!1),C=h(null),Q=h(null);let $=[];const I=()=>{Be().then(({data:s})=>{if(s){if(!r.value){X();return}if(p.value||(C.value.execute("clear"),C.value.execute("开始升级")),s.log.forEach(u=>{$.includes(u)||(C.value.pushMessage({content:`正在执行:${u}`}),$.push(u))}),s.error){p.value=s,Z({message:"升级失败",type:"error"}),C.value.pushMessage({content:s.error,class:"error"});return}if(s.step=="upgradeComplete"){m.value="complete",V&&V.close(),ee("complete");return}p.value=s,W()}}).catch()};I();const W=()=>{Ee().then(()=>{I()}).catch()};let V=null;const X=()=>{V=ne.success({title:a("warning"),dangerouslyUseHTMLString:!0,message:J("div",{},[a("upgrade.upgradingTips"),J("span",{class:"text-primary cursor-pointer",onClick:D},[a("upgrade.clickView")])]),duration:0,showClose:!1})},D=()=>{r.value=!0,m.value="upgrade",I(),V&&V.close()},P=async()=>{var u,E;if(b.value)return;b.value=!0;const s=((u=d.value)==null?void 0:u.app.app_key)!="niucloud-admin"?(E=d.value)==null?void 0:E.app.app_key:"";await $e(s).then(async({data:U})=>{U.is_pass?await Te(s).then(()=>{I()}).catch(()=>{b.value=!1}):w.value=U}).catch(),b.value&&(m.value="upgrade")},Y=(s="")=>{if(p.value){Z({message:"已有正在执行中的升级任务",type:"error"}),r.value=!0;return}Ce(s).then(({data:u})=>{if(d.value=u,!u.version_list.length){Z({message:"已经是最新版本了",type:"error"});return}r.value=!0}).catch()};let H=null;const z=new fe,_=(s,u,E,U,N)=>{if(u=="开始升级"){E(z);const k=f(["/","——","\\","|"]);H=setInterval(()=>{z.flush("> "+k.next().value)},150)}},f=s=>{var u=0;return{next(){return u+1==s.length&&(u=0),{value:s[u++]}}}},v=s=>{m.value=="upgrade"&&p.value&&!p.value.error?oe.confirm(a("upgrade.showDialogCloseTips"),a("warning"),{confirmButtonText:a("confirm"),cancelButtonText:a("cancel"),type:"warning"}).then(()=>{s()}).catch(()=>{}):s()};se(()=>r.value,()=>{r.value||x()});const x=()=>{p.value=null,$=[],H&&clearInterval(H),Ie().then(()=>{}).catch()},j=()=>{var s;r.value=!1,(s=Q.value)==null||s.open()};return O({open:Y}),(s,u)=>{const E=ke,U=ie,N=ye,k=ue,B=ce,le=K("Select"),G=re,te=K("CloseBold"),ge=de,he=pe;return n(),c(R,null,[e(he,{modelValue:r.value,"onUpdate:modelValue":u[1]||(u[1]=y=>r.value=y),title:i(a)("upgrade.title"),width:"850px","close-on-click-modal":!1,"close-on-press-escape":!1,"before-close":v},{default:l(()=>[L(t("div",null,[d.value?(n(),c("div",We,[t("div",Xe,[S(" 本次升级将从"),t("span",Ye,o(d.value.version),1),S("升级到"),t("span",Ze,o(d.value.upgrade_version),1),S("版本 ")]),d.value.upgrade_version!=d.value.last_version?(n(),c("div",el,[e(E,{type:"info","show-icon":""},{title:l(()=>[S(" 当前最新版本为"+o(d.value.last_version)+",您的服务已于"+o(d.value.expire_time)+"到期。如需升级到最新版可在",1),ll,S("购买相关服务后再进行升级 ")]),_:1})])):F("",!0),e(U,{class:"flex-1 h-0 mt-[20px]"},{default:l(()=>[(n(!0),c(R,null,A(d.value.version_list,(y,me)=>(n(),c("div",{class:"mt-[20px]",key:me},[t("div",tl,o(y.version_no),1),t("div",al,o(y.release_time),1),y.upgrade_log?(n(),c("div",{key:0,class:"mt-[10px] p-[10px] rounded bg-[#f4f4f5] whitespace-pre",innerHTML:y.upgrade_log},null,8,sl)):F("",!0)]))),128))]),_:1})])):F("",!0),t("div",nl,[e(N,{type:"primary",onClick:P,loading:b.value},{default:l(()=>[S(o(i(a)("upgrade.upgradeButton")),1)]),_:1},8,["loading"])])],512),[[M,m.value=="content"]]),L(t("div",null,[w.value&&!p.value?(n(),c("div",ol,[e(U,null,{default:l(()=>[w.value.dir?(n(),c("div",ul,[t("p",cl,o(i(a)("upgrade.dirPermission")),1),t("div",rl,[e(B,{class:"py-[10px] items table-head-bg pl-[15px] mb-[10px]"},{default:l(()=>[e(k,{span:12},{default:l(()=>[t("span",null,o(i(a)("upgrade.path")),1)]),_:1}),e(k,{span:6},{default:l(()=>[t("span",null,o(i(a)("upgrade.demand")),1)]),_:1}),e(k,{span:6},{default:l(()=>[t("span",null,o(i(a)("status")),1)]),_:1})]),_:1}),(n(!0),c(R,null,A(w.value.dir.is_readable,y=>(n(),q(B,{class:"pb-[10px] items pl-[15px]"},{default:l(()=>[e(k,{span:12},{default:l(()=>[t("span",null,o(y.dir),1)]),_:2},1024),e(k,{span:6},{default:l(()=>[t("span",null,o(i(a)("upgrade.readable")),1)]),_:1}),e(k,{span:6},{default:l(()=>[y.status?(n(),c("span",il,[e(G,{color:"green"},{default:l(()=>[e(le)]),_:1})])):(n(),c("span",dl,[e(G,{color:"red"},{default:l(()=>[e(te)]),_:1})]))]),_:2},1024)]),_:2},1024))),256)),(n(!0),c(R,null,A(w.value.dir.is_write,y=>(n(),q(B,{class:"pb-[10px] items pl-[15px]"},{default:l(()=>[e(k,{span:12},{default:l(()=>[t("span",null,o(y.dir),1)]),_:2},1024),e(k,{span:6},{default:l(()=>[t("span",null,o(i(a)("upgrade.write")),1)]),_:1}),e(k,{span:6},{default:l(()=>[y.status?(n(),c("span",pl,[e(G,{color:"green"},{default:l(()=>[e(le)]),_:1})])):(n(),c("span",_l,[e(G,{color:"red"},{default:l(()=>[e(te)]),_:1})]))]),_:2},1024)]),_:2},1024))),256))])])):F("",!0)]),_:1})])):F("",!0),L(t("div",fl,[e(i(ve),{ref_key:"terminalRef",ref:C,context:p.value?p.value.upgrade.app_key:"","init-log":null,"show-header":!1,"show-log-time":!0,onExecCmd:_},null,8,["context"])],512),[[M,p.value]])],512),[[M,m.value=="upgrade"]]),L(t("div",null,[t("div",vl,[t("div",gl,[e(ge,{icon:"success",title:i(a)("upgrade.upgradeSuccess")},null,8,["title"]),e(E,{title:i(a)("upgrade.upgradeCompleteTips"),type:"error",closable:!1},null,8,["title"])]),t("div",hl,[e(N,{type:"default",onClick:u[0]||(u[0]=y=>r.value=!1)},{default:l(()=>[S(o(i(a)("upgrade.localBuild")),1)]),_:1}),e(N,{type:"primary",onClick:j},{default:l(()=>[S(o(i(a)("upgrade.cloudBuild")),1)]),_:1})])])],512),[[M,m.value=="complete"]])]),_:1},8,["modelValue","title"]),e(Oe,{ref_key:"cloudBuildRef",ref:Q},null,512)],64)}}});const $l=_e(ml,[["__scopeId","data-v-dd711ee6"]]);export{Oe as C,$l as U};
|