全栈小学生 eff269ab88 up
2025-09-20 09:12:11 +08:00

2 lines
8.5 KiB
JavaScript

import{ar as F,d as re,r,X as de,al as _e,N as L,h as d,m as R,w as l,J as T,c as b,a as t,t as x,u as _,k as n,e,F as K,T as O,B as W,ae as D,i as y,a4 as Y,Q as ve,av as pe,aw as fe,a2 as me,E as xe,a_ as he,S as ge,M as be,p as we,g as ke,_ as ye}from"./index-9f163f98.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{T as Ie,_ as Ce,a as Be,b as Se}from"./dark-d503b80a.js";function Te(){return F.post("niucloud/build",{})}function De(){return F.get("niucloud/build")}function Fe(){return F.get("niucloud/build/log")}function Q(){return F.post("niucloud/build/clear")}function Ee(){return F.get("niucloud/build/check")}const V=E=>(we("data-v-a071d5db"),E=E(),ke(),E),$e={class:"h-[50vh]"},Me={key:0,class:"h-[50vh] flex flex-col"},Ne={key:0,class:"bg-[#fff] my-3"},Ve={class:"pl-[20px]"},je={class:"flex items-center"},Le=V(()=>t("span",{class:"ml-[5px] leading-[20px]"},"编译权限错误,查看解决方案",-1)),Re=V(()=>t("div",{class:"border-[1px] border-primary rounded-[3px] w-[72px] h-[26px] leading-[25px] text-center"},"立即查看",-1)),Qe={class:"px-[20px] pt-[10px] text-[14px] el-table"},qe={key:0},ze={key:1},Je={key:0},Pe={key:1},Ue={class:"h-[45vh]"},Xe={class:"flex justify-end mt-[20px]"},Ae={class:"h-[50vh] flex flex-col"},Ge={class:"flex-1 h-0 flex justify-center items-center flex-col"},He=V(()=>t("img",{src:Be,alt:""},null,-1)),Ke={class:"h-[50vh] flex flex-col"},Oe={class:"flex-1 h-0 flex justify-center items-center flex-col"},We=V(()=>t("img",{src:Se,alt:""},null,-1)),Ye=re({__name:"index",setup(E,{expose:Z}){const s=r(!1),ee=r(Date.now()),p=r(null),v=r("build"),C=r(null),w=r(!1),h=r(null);let B=[];const f=r(null),k=r(0);let c=null;const q=de(()=>{const o=k.value,a=Math.floor(o/60),g=o%60;return a>0?`${a}${g}`:`${g}`}),z=()=>{De().then(({data:o})=>{o&&(p.value=o,s.value||localStorage.setItem("cloud_build_task","true"))}).catch()};z();const J=r(""),$=r(!1),M=()=>{$.value=!0,Fe().then(o=>{if(!o.data){s.value&&B.length&&(v.value="complete",$.value=!1,h.value.execute("clear"),Q(),c&&clearInterval(c),localStorage.removeItem("cloud_build_start_time"),localStorage.removeItem("cloud_build_task"));return}const a=o.data.data??[];let g="";if(a[0]&&a[0].length&&s.value){if(B.length==0){const u=localStorage.getItem("cloud_build_start_time");if(u)f.value=Number(u);else{const i=Date.now();f.value=i,localStorage.setItem("cloud_build_start_time",String(i))}k.value=Math.floor((Date.now()-f.value)/1e3),c&&clearInterval(c),c=setInterval(()=>{f.value&&(k.value=Math.floor((Date.now()-f.value)/1e3))},1e3),h.value.execute("clear"),h.value.execute("开始编译")}a[0].forEach(u=>{B.includes(u.action)||(h.value.pushMessage({content:`${u.action}`}),B.push(u.action),u.code==0&&(g=u.msg,h.value.pushMessage({content:u.msg,class:"error"}),$.value=!1,v.value="error",h.value.execute("clear"),Q(),J.value=u.msg,c&&(clearInterval(c),c=null),f.value&&(k.value=Math.floor((Date.now()-f.value)/1e3)),localStorage.removeItem("cloud_build_start_time"),localStorage.removeItem("cloud_build_task")))})}g||setTimeout(()=>{M()},2e3)}).catch()},N=r("normal"),P=()=>{v.value="build",N.value="success"},le=()=>{s.value=!0,v.value="build",M()},te=async()=>{if(w.value=!0,v.value="build",N.value="normal",p.value){s.value=!0,w.value=!1,M();return}Ee().then(async({data:o})=>{o.is_pass?Te().then(({data:a})=>{w.value=!1,p.value=a,s.value=!0,M()}).catch(()=>{s.value=!1,w.value=!1}):(w.value=!1,C.value=o,s.value=!0)}).catch(()=>{s.value=!1})};let j=null;const U=new Ie,ae=(o,a,g,u,i)=>{if(a=="开始编译"){g(U);const S=oe(["/","——","\\","|"]);j=setInterval(()=>{U.flush("> "+S.next().value)},150)}},oe=o=>{let a=0;return{next(){return a+1==o.length&&(a=0),{value:o[a++]}}}},se=o=>{v.value=="build"&&p.value&&N.value=="normal"?Y.confirm(n("cloudbuild.showDialogCloseTips"),n("warning"),{confirmButtonText:n("confirm"),cancelButtonText:n("cancel"),type:"warning"}).then(()=>{h.value.execute("clear"),localStorage.removeItem("cloud_build_start_time"),localStorage.removeItem("cloud_build_task"),o(),c&&clearInterval(c),c=null,f.value=null,k.value=0}).catch(()=>{}):o()},ue=()=>{v.value=="build"&&p.value&&N.value=="normal"?Y.confirm(n("cloudbuild.showDialogCloseTips"),n("warning"),{confirmButtonText:n("confirm"),cancelButtonText:n("cancel"),type:"warning"}).then(()=>{h.value.execute("clear"),localStorage.removeItem("cloud_build_start_time"),localStorage.removeItem("cloud_build_task"),c&&clearInterval(c),c=null,f.value=null,k.value=0,s.value=!1}).catch(()=>{}):s.value=!1},ne=()=>{window.open("https://doc.niucloud.com/v6.html?keywords=/chang-jian-wen-ti-chu-li/er-shi-wu-3001-sheng-7ea7-yun-bian-yi-mu-lu-du-xie-quan-xian-zhuang-tai-bu-tong-guo-ru-he-chu-li")};return _e(()=>s.value,()=>{s.value||(p.value=null,v.value="build",B=[],j&&clearInterval(j),c&&clearInterval(c),f.value=null,k.value=0,Q())}),Z({open:te,cloudBuildTask:p,loading:w,elNotificationClick:le,getCloudBuildTaskFn:z}),(o,a)=>{const g=L("QuestionFilled"),u=ve,i=pe,S=fe,X=L("Select"),A=L("CloseBold"),G=me,I=xe,H=he,ce=ge,ie=be;return d(),R(ce,{modelValue:s.value,"onUpdate:modelValue":a[3]||(a[3]=m=>s.value=m),title:_(n)("cloudbuild.title"),width:"850px","close-on-click-modal":!1,"close-on-press-escape":!1,"before-close":se},{default:l(()=>[T((d(),b("div",$e,[C.value&&!p.value?(d(),b("div",Me,[C.value.dir?(d(),b("div",Ne,[t("div",null,[t("p",Ve,x(_(n)("cloudbuild.dirPermission")),1),t("div",{class:"mt-[10px] mx-[20px] text-[14px] cursor-pointer text-primary flex items-center justify-between bg-[#EFF6FF] rounded-[4px] p-[10px]",onClick:ne},[t("div",je,[e(u,{size:17},{default:l(()=>[e(g)]),_:1}),Le]),Re])]),t("div",Qe,[e(S,{class:"py-[10px] items table-head-bg pl-[15px] mb-[10px]"},{default:l(()=>[e(i,{span:18},{default:l(()=>[t("span",null,x(_(n)("cloudbuild.path")),1)]),_:1}),e(i,{span:3},{default:l(()=>[t("span",null,x(_(n)("cloudbuild.demand")),1)]),_:1}),e(i,{span:3},{default:l(()=>[t("span",null,x(_(n)("status")),1)]),_:1})]),_:1}),e(G,{style:{height:"calc(300px)",overflow:"auto"}},{default:l(()=>[(d(!0),b(K,null,O(C.value.dir.is_readable,m=>(d(),R(S,{class:"pb-[10px] items pl-[15px]"},{default:l(()=>[e(i,{span:18},{default:l(()=>[t("span",null,x(m.dir),1)]),_:2},1024),e(i,{span:3},{default:l(()=>[t("span",null,x(_(n)("cloudbuild.readable")),1)]),_:1}),e(i,{span:3},{default:l(()=>[m.status?(d(),b("span",qe,[e(u,{color:"green"},{default:l(()=>[e(X)]),_:1})])):(d(),b("span",ze,[e(u,{color:"red"},{default:l(()=>[e(A)]),_:1})]))]),_:2},1024)]),_:2},1024))),256)),(d(!0),b(K,null,O(C.value.dir.is_write,m=>(d(),R(S,{class:"pb-[10px] items pl-[15px]"},{default:l(()=>[e(i,{span:18},{default:l(()=>[t("span",null,x(m.dir),1)]),_:2},1024),e(i,{span:3},{default:l(()=>[t("span",null,x(_(n)("cloudbuild.write")),1)]),_:1}),e(i,{span:3},{default:l(()=>[m.status?(d(),b("span",Je,[e(u,{color:"green"},{default:l(()=>[e(X)]),_:1})])):(d(),b("span",Pe,[e(u,{color:"red"},{default:l(()=>[e(A)]),_:1})]))]),_:2},1024)]),_:2},1024))),256))]),_:1})])])):W("",!0)])):W("",!0),T(t("div",Ue,[e(_(Ce),{ref_key:"terminalRef",ref:h,name:`cloud-build-${ee.value}`,context:"","init-log":null,"show-header":!1,"show-log-time":!0,onExecCmd:ae},null,8,["name"])],512),[[D,p.value]]),T(t("div",Xe,[e(I,{onClick:a[0]||(a[0]=m=>ue()),class:"!w-[90px]"},{default:l(()=>[y("取消")]),_:1}),e(I,{type:"primary",loading:$.value,class:"!w-[140px]"},{default:l(()=>[y("已用时 "+x(_(q)),1)]),_:1},8,["loading"])],512),[[D,p.value]])])),[[D,v.value=="build"],[ie,w.value]]),T(t("div",null,[t("div",Ae,[t("div",Ge,[e(H,{icon:"error",title:_(n)("编译失败")},{icon:l(()=>[He]),extra:l(()=>[e(G,{class:"max-h-[150px] !overflow-auto text-[15px] text-[#4F516D] mb-[15px] mt-[-15px]"},{default:l(()=>[y(x(J.value),1)]),_:1}),e(I,{onClick:P,class:"!w-[90px]"},{default:l(()=>[y("错误信息")]),_:1}),e(I,{onClick:a[1]||(a[1]=m=>s.value=!1),type:"primary",class:"!w-[90px]"},{default:l(()=>[y("完成")]),_:1})]),_:1},8,["title"])])])],512),[[D,v.value=="error"]]),T(t("div",null,[t("div",Ke,[t("div",Oe,[e(H,{icon:"success",title:_(n)("cloudbuild.cloudbuildSuccess"),"sub-title":`编译耗时${_(q)},成功编译完成。`},{icon:l(()=>[We]),extra:l(()=>[e(I,{onClick:P,class:"!w-[90px]"},{default:l(()=>[y("返回")]),_:1}),e(I,{onClick:a[2]||(a[2]=m=>s.value=!1),type:"primary",class:"!w-[90px]"},{default:l(()=>[y("完成")]),_:1})]),_:1},8,["title","sub-title"])])])],512),[[D,v.value=="complete"]])]),_:1},8,["modelValue","title"])}}});const cl=ye(Ye,[["__scopeId","data-v-a071d5db"]]);export{cl as default};