import{M as a,aK as e,P as l,j as s}from"./utils-lib.js?v=1761009159";import{c as t,r as o,o as n,v as r,x as u,e as d,B as i,F as m,b0 as c,C as f,z as p,y as v,Q as b,G as y,aq as _,ap as x,al as w,ab as S,a9 as T,A as g,N as h,ar as j,ak as V}from"./base-lib.js?v=1761009159";import{g as k}from"./useStore2.js?v=1761009159";import{syncDataToPanel as q,syncModuleDataToPanel as C}from"./database.js?v=1761009159";import{r as L,n as M}from"./useMethod4.js?v=1761009159";const F={class:"inline-block flex flex-col py-[1.2rem] mb-[0.8rem]"},N={class:"text-secondary text-base mb-[8px]"},A=["innerHTML"],D={class:"p-[16px]"},H=t({__name:"index",props:{compData:{default:()=>[]}},setup(t){var H;const P=t,{refs:{tabActive:R,isRefreshClassList:U},refreshTableList:z}=k(),B=o(P.compData),G=o((null==(H=B.value[0])?void 0:H.id)||""),J=n({}),K=o(),O=o(!1),Q=[{label:"从面板同步到服务器",name:"SyncToServer",description:"将面板的数据库同步到本地服务器中"},{label:"从服务器同步到面板",name:"SyncToPanel",description:"从服务器获取所有数据库，并同步到面板中<br>（数据库密码无法同步，需在面板重新配置）"}],E=async a=>{if("SyncToServer"===a)I();else{const a=await L();G.value=a[0].id,B.value=a,O.value=!0}},I=async()=>{const l=a.load("正在同步...");try{const e=await M();a.request(e),z()}catch(s){e(s,"syncToServer")}finally{l.close()}},W=async()=>{await K.value.validate();let a={sid:Number(G.value)};await l({loading:"正在获取数据库,请稍候...",request:"mysql"===R.value?q(a):C({data:JSON.stringify(a)},R.value),message:!0}),U.value=!0,setTimeout(()=>{z()},1e3)};return(a,e)=>{const l=y,t=j,o=_,n=x,k=V,q=w,C=S,L=T,M=s;return r(),u("div",null,[d(n,{onCommand:E},{dropdown:i(()=>[d(o,null,{default:i(()=>[(r(),u(m,null,c(Q,(a,e)=>d(t,{command:a.name,key:e},{default:i(()=>[p("div",F,[p("span",N,g(a.label),1),p("span",{class:"text-tertiary text-small leading-1.8rem",innerHTML:a.description},null,8,A)])]),_:2},1032,["command"])),64))]),_:1})]),default:i(()=>[d(l,{type:"default"},{default:i(()=>e[2]||(e[2]=[f(" 同步数据库 ",-1),p("i",{class:"svgtofont-el-arrow-down ml-4px"},null,-1)])),_:1,__:[2]})]),_:1}),d(M,{title:"从服务器获取",modelValue:v(O),"onUpdate:modelValue":e[1]||(e[1]=a=>b(O)?O.value=a:null),area:46,onConfirm:W,showFooter:""},{default:i(()=>[p("div",D,[d(L,{ref_key:"syncFormRef",ref:K,model:v(J)},{default:i(()=>[d(C,{label:"数据库位置"},{default:i(()=>[d(q,{modelValue:v(G),"onUpdate:modelValue":e[0]||(e[0]=a=>b(G)?G.value=a:null),class:"!w-[28rem]"},{default:i(()=>[(r(!0),u(m,null,c(v(B),(a,e)=>(r(),h(k,{key:e,value:a.id,label:a.ps+"（服务器地址："+a.db_host+"）"},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"])])]),_:1},8,["modelValue"])])}}});export{H as _};
