import{l as e,x as a,L as l}from"./utils-lib.js?v=20260328163632";import{u as s}from"./store.js?v=20260328163632";import{a as t,b as o}from"./database.js?v=20260328163632";import{k as r}from"./useMethod2.js?v=20260328163632";import{E as n,B as u,n as i,v as c,w as p}from"./naive-ui.js?v=20260328163632";import{k as d,r as v,e as m,V as f,W as b,O as x,a3 as y,Y as w,N as _,j as g,Z as h,X as S}from"./base-lib.js?v=20260328163632";const j={class:"p-[16px]"},k=d({__name:"index",props:{compData:{default:()=>[]}},setup(d){var k;const T=d,{tabActive:V,isRefreshList:L}=s(),q=v(T.compData),C=v((null==(k=q.value[0])?void 0:k.value)||""),D=m({}),F=v(),M=v(!1),N=[{key:"SyncToServer",type:"render",render:()=>P("SyncToServer",e("从面板同步到服务器"),e("将面板的数据库同步到本地服务器中"))},{key:"SyncToPanel",type:"render",render:()=>P("SyncToPanel",e("从服务器同步到面板"),"".concat(e("从服务器获取所有数据库，并同步到面板中"),"<br>").concat(e("（数据库密码无法同步，需在面板重新配置）")))}],P=(e,a,l)=>x("div",{onClick:()=>R(e),class:"inline-block flex flex-col p-[12px] cursor-pointer hover:bg-[var(--bg-highlight-row)]"},[x("span",{class:"text-[var(--text-color-2)] text-[14px] mb-[8px]"},[a]),x("span",{class:"text-[var(--text-color-3)] text-[12px] leading-[18px]",innerHTML:l},null)]),R=async e=>{if("SyncToServer"===e)U();else{const e=await r();C.value=e[0].id,q.value=e.map((e=>({...e,label:"".concat(e.ps,"(").concat(e.db_host,")"),value:e.id}))),M.value=!0}},U=async()=>{a({loading:e("正在同步..."),request:t({db_type:V.value}),message:!0,success:()=>{L.value=!0}})},A=async()=>{await F.value.validate();let l={sid:Number(C.value),db_type:V.value};await a({loading:e("正在获取数据库,请稍候..."),request:o(l),message:!0}),L.value=!0};return(a,s)=>{const t=u,o=n,r=i,d=c,v=p;return f(),b("section",null,[x(o,{options:N,"show-arrow":!0,onSelect:R},{default:y((()=>[x(t,{type:"default"},{default:y((()=>[g(h(w(e)("同步数据库"))+" ",1),s[2]||(s[2]=S("i",{class:"svgtofont-el-arrow-down ml-4px"},null,-1))])),_:1})])),_:1}),x(w(l),{title:w(e)("从服务器获取"),modelValue:w(M),"onUpdate:modelValue":s[1]||(s[1]=e=>_(M)?M.value=e:null),area:460,onConfirm:A,showFooter:""},{default:y((()=>[S("div",j,[x(v,{ref_key:"syncFormRef",ref:F,"label-placement":"left","label-width":110,model:w(D)},{default:y((()=>[x(d,{label:w(e)("数据库位置")},{default:y((()=>[x(r,{value:w(C),"onUpdate:value":s[0]||(s[0]=e=>_(C)?C.value=e:null),options:w(q),class:"!w-[280px]"},null,8,["value","options"])])),_:1},8,["label"])])),_:1},8,["model"])])])),_:1},8,["title","modelValue"])])}}});export{k as _};
