import{P as a,l,k as e,j as s}from"./utils-lib.js?v=1761009159";import{c as d,r as t,q as u,H as o,v as n,x as i,I as r,y as m,e as p,B as c,z as b,Q as v,F as _,b0 as f,N as V,C as q,ab as y,ak as j,al as w,a9 as x}from"./base-lib.js?v=1761009159";import{getSiteInfo as g,getMysqlInfo as h,modifyMysqlLink as k}from"./database.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const U={class:"p-[20px]"},C=d({__name:"index",setup(d,{expose:C}){const H=t(!1),z=t(!1),A=t([]),B=t([]),F=t({sql_id:"",pid:"",database:""}),I=[{prop:"name",label:"数据库"},{label:"站点名称",render:function(a){return p("div",null,[a.rname||"--"," ",p("span",{class:"cursor-pointer bt-link",onClick:()=>N(a)},[q("切换")])])}}],N=async a=>{var l;try{const e=await g();A.value=e.data,F.value.database=a.name,F.value.sql_id=a.id,F.value.pid=a.pid?a.pid:null==(l=A.value[0])?void 0:l.id,H.value=!0}catch(e){}},P=async()=>{await a({request:h(),loading:z,data:[Array,B]})},Q=async()=>{const l={pid:F.value.pid,sql_id:F.value.sql_id};await a({request:k(l),loading:"正在切换中...",message:!0,success:()=>{H.value=!1,P()}})};return u(P),C({init:P}),(a,d)=>{const t=l,u=e,q=y,g=j,h=w,k=x,C=s,N=o("bt-loading");return n(),i("div",null,[r(p(t,{"max-height":"560",column:I,data:m(B)},null,8,["data"]),[[N,m(z)]]),p(C,{title:"切换网站",modelValue:m(H),"onUpdate:modelValue":d[3]||(d[3]=a=>v(H)?H.value=a:null),area:42,"show-footer":"",onConfirm:Q},{default:c(()=>[b("div",U,[p(k,{modelValue:m(F),"onUpdate:modelValue":d[2]||(d[2]=a=>v(F)?F.value=a:null)},{default:c(()=>[p(q,{label:"数据库"},{default:c(()=>[p(u,{disabled:"",modelValue:m(F).database,"onUpdate:modelValue":d[0]||(d[0]=a=>m(F).database=a),width:"24rem"},null,8,["modelValue"])]),_:1}),p(q,{label:"站点名称"},{default:c(()=>[p(h,{modelValue:m(F).pid,"onUpdate:modelValue":d[1]||(d[1]=a=>m(F).pid=a),class:"!w-[24rem]"},{default:c(()=>[(n(!0),i(_,null,f(m(A),(a,l)=>(n(),V(g,{key:l,label:a.rname,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["modelValue"])])]),_:1},8,["modelValue"])])}}});export{C as default};
