import{ju as a,M as s,x as e,jv as t,$ as l,_ as n}from"./utils-lib.js?v=1761009159";import{_ as i}from"./index119.js?v=1761009159";import{c as o,r,q as u,a6 as c,v as m,x as p,e as v,B as d,F as _,b0 as f,y as x,N as g,cb as j,cc as y,z as b,A as w,C as h,D as k,G as z}from"./base-lib.js?v=1761009159";import{a as C}from"./index63.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index105.js?v=1761009159";import"./column.js?v=1761009159";import"./index106.js?v=1761009159";import"./useController6.js?v=1761009159";import"./site.js?v=1761009159";import"./validator.js?v=1761009159";import"./useStore4.js?v=1761009159";const D={class:"p-[2rem] master-step-container"},q={key:0,class:"manual-import-card"},T={class:"file-name"},H={class:"file-size"},I={class:"manual-import-actions"},N=n(o({__name:"index",props:{compData:{default:()=>({slave_ip:""})}},setup(n){const{isRefreshList:o}=C(),N=n,S=r(""),A=r([]),B=r(0);let F=null;const G=r(""),L=r(0),M=r({}),R=r(!0),$={wait:()=>v("span",{class:"svgtofont-el-more-filled text-disabled mr-2px !text-large"},null),done:()=>v("span",{class:"svgtofont-el-circle-check text-primary mr-2px !text-large"},null),running:()=>v("span",{class:"svgtofont-el-loading animate-spin text-supplement mr-2px !text-large"},null)},E={wait:"",done:"完成",running:"进行中"},J=async()=>{if(!R.value)return;const{data:t}=await a({slave_ip:N.compData.slave_ip});t.status||s.error(t.msg);const{data:l}=t,{data:n}=l;S.value=n.logs,A.value=n.steps||[],B.value=A.value.findIndex(a=>"running"===a.status||"wait"===a.status),-1===B.value&&(B.value=A.value.length-1),L.value=n.step,G.value=l.sync_type,"manual"===G.value&&2===L.value&&(R.value=!1,M.value={name:n.master_data_sql,size:e(Number(n.sql_file_size))||"--"});const i=n.step,r=A.value[A.value.length-1];5===i&&r&&"done"===r.status?F&&(clearTimeout(F),F=null,o.value=!0):A.value.some(a=>"done"!==a.status)&&(F=setTimeout(J,2e3))},K=async()=>{const a=s.load("开始同步...");try{const{data:a}=await t({slave_ip:N.compData.slave_ip});a.status?(R.value=!0,o.value=!0,J()):s.error(a.msg||"同步失败")}catch(e){s.error("同步失败")}finally{a.close()}},O=()=>{window.open("/download?filename="+M.value.name)};return u(()=>{R.value=!0,J()}),c(()=>{S.value="",F&&(clearTimeout(F),F=null)}),(a,s)=>{const e=z,t=i,n=l;return m(),p("div",D,[v(x(y),{direction:"vertical",space:"4rem",active:x(B)},{default:d(()=>[(m(!0),p(_,null,f(x(A),(a,s)=>{var e;return m(),g(x(j),{key:s,title:a.msg,icon:$[a.status]?$[a.status]():$.wait(),description:null!=(e=E[a.status])?e:"",status:"done"===a.status?"success":"running"===a.status?"process":"wait"},null,8,["title","icon","description","status"])}),128))]),_:1},8,["active"]),2===x(L)&&"manual"===x(G)?(m(),p("div",q,[b("div",T,"文件名："+w(x(M).name),1),b("div",H,"大小："+w(x(M).size),1),s[2]||(s[2]=b("div",{class:"import-tip"},"提示：请下载上面主库备份文件，在从库数据库页面-选择任意一个需要同步的数据库，进行导入数据",-1)),b("div",I,[v(e,{onClick:O},{default:d(()=>s[0]||(s[0]=[h("点击下载",-1)])),_:1,__:[0]}),v(e,{type:"primary",onClick:K},{default:d(()=>s[1]||(s[1]=[h("数据已导入，开始从库配置",-1)])),_:1,__:[1]})])])):k("",!0),s[3]||(s[3]=b("h3",{class:"text-base mb-[1rem] mt-[1rem] color-[#666]"},"实时日志",-1)),v(t,{content:x(S),isHtml:!0,autoScroll:!0,style:{height:"14rem"}},null,8,["content"]),v(n,{options:[{content:"同步任务为后台进行，此页面可以关闭，在从库列表中可以重新打开"}],class:"mt-[1rem]"})])}}}),[["__scopeId","data-v-877f13be"]]);export{N as default};
