import{_ as N}from"./index.vue_vue_type_script_setup_true_lang-D8O2mMsP.js?v=1773287522785";import{_ as B,g4 as V,m as q}from"./index-BTglIPU2.js?v=1773287522785";import{_ as E}from"./index.vue_vue_type_script_setup_true_lang-DG86e1NA.js?v=1773287522785";import{k as L,R as O,a6 as j,r as _,e as I,c as M,$ as b,a8 as v,a9 as r,a0 as n,_ as d,S as t,ak as g,j as Q,aa as T,N as z}from"./vue-core-DJjvd5ZC.js?v=1773287522785";import{u as P}from"./index-B5d4M70B.js?v=1773287522785";import{g as F}from"./index-wgWqrNqx.js?v=1773287522785";import{a1 as G,b as H,a6 as J,a8 as K}from"./naive-ui--dJnpVcV.js?v=1773287522785";import"./prismjs-BZPoR7_J.js?v=1773287522785";import"./index-K4YGya6V.js?v=1773287522785";import"./index-COOnaZWq.js?v=1773287522785";const W={class:"w-240px"},X={class:"w-100px ml-8px"},Y={class:"w-240px"},Z={class:"w-240px"},ee={class:"w-240px"},ae={class:"w-240px"},se={class:"w-240px"},te={class:"ml-8px"},ge=L({__name:"index",setup(oe,{expose:w}){const{t:l}=O(),c=P(),{remoteList:p}=j(c),f=_(null),a=I({sid:p.value.length>0?p.value[0].id:null,name:"",codeing:"utf8mb4",db_user:"",password:"",dataAccess:"127.0.0.1",address:"127.0.0.1",active:!1,ssl:""}),x=_([{label:"utf-8",value:"utf8"},{label:"utf8mb4",value:"utf8mb4"},{label:"gbk",value:"gbk"},{label:"big5",value:"big5"}]),h=_([{label:l("Database.form.index_12"),value:"127.0.0.1"},{label:l("Database.form.index_13"),value:"%"},{label:l("Database.form.index_14"),value:"ip"}]),D=M(()=>p.value.map(e=>({label:"".concat(e.ps," (").concat(e.db_host,")"),value:e.id}))),$={name:{required:!0,message:l("Database.form.index_15"),trigger:["blur","change"]},db_user:{required:!0,message:l("Database.form.index_16"),trigger:["blur","change"]},password:{required:!0,message:l("Database.form.index_17"),trigger:["blur","change"]},sid:{trigger:"change",validator:(e,s)=>s===null?new Error(l("Database.form.index_18")):!0}},k=e=>{a.db_user=e},U=e=>{e==="ip"?a.address="":a.address=e},ne=e=>{a.ssl=e?"REQUIRE SSL":""},R=()=>{F()},y=()=>{const e=z(a),{sid:s}=e;if(s===null)throw q.error(l("Database.form.index_18")),new Error(l("Database.form.index_18"));return{...e,sid:s,ps:e.name,dtype:"MySQL",address:a.dataAccess==="ip"?a.address.trim().split("\n").join(","):a.address}};return w({onConfirm:async()=>{var e;await((e=f.value)==null?void 0:e.validate());try{const s=y();await V(s),c.setRefresh(!0)}catch(s){console.warn(s)}}}),(e,s)=>{const u=H,m=J,i=G,S=E,A=B,re=K,C=N;return b(),v(C,{ref_key:"formRef",ref:f,model:t(a),rules:$,class:"p-20px"},{default:r(()=>[n(i,{label:e.$t("Database.form.index_1"),path:"name"},{default:r(()=>[d("div",W,[n(u,{value:t(a).name,"onUpdate:value":[s[0]||(s[0]=o=>t(a).name=o),k],placeholder:e.$t("Database.form.index_2"),"input-props":{name:"name"}},null,8,["value","placeholder"])]),d("div",X,[n(m,{value:t(a).codeing,"onUpdate:value":s[1]||(s[1]=o=>t(a).codeing=o),class:"code-select",options:t(x)},null,8,["value","options"])])]),_:1},8,["label"]),n(i,{label:e.$t("Database.form.index_3"),path:"db_user"},{default:r(()=>[d("div",Y,[n(u,{value:t(a).db_user,"onUpdate:value":s[2]||(s[2]=o=>t(a).db_user=o),placeholder:e.$t("Database.form.index_4"),"input-props":{name:"username"}},null,8,["value","placeholder"])])]),_:1},8,["label"]),n(i,{label:e.$t("Database.form.index_5"),path:"password"},{default:r(()=>[d("div",Z,[n(S,{value:t(a).password,"onUpdate:value":s[3]||(s[3]=o=>t(a).password=o),placeholder:"","input-props":{name:"password"}},null,8,["value"])])]),_:1},8,["label"]),n(i,{label:e.$t("Database.form.index_6"),path:"dataAccess"},{default:r(()=>[d("div",ee,[n(m,{value:t(a).dataAccess,"onUpdate:value":[s[4]||(s[4]=o=>t(a).dataAccess=o),U],class:"access-select",options:t(h)},null,8,["value","options"])])]),_:1},8,["label"]),t(a).dataAccess==="ip"?(b(),v(i,{key:0,label:e.$t("Database.form.index_7"),path:"address"},{default:r(()=>[d("div",ae,[n(u,{value:t(a).address,"onUpdate:value":s[5]||(s[5]=o=>t(a).address=o),type:"textarea",autosize:{minRows:3,maxRows:3},"input-props":{name:"address"},placeholder:e.$t("Database.form.index_8")},null,8,["value","placeholder"])])]),_:1},8,["label"])):g("",!0),n(i,{label:e.$t("Database.form.index_9"),path:"sid"},{default:r(()=>[d("div",se,[n(m,{value:t(a).sid,"onUpdate:value":s[6]||(s[6]=o=>t(a).sid=o),class:"sid-select",options:t(D)},null,8,["value","options"])]),d("div",te,[n(A,{onClick:R},{default:r(()=>[Q(T(e.$t("Database.form.index_10")),1)]),_:1})])]),_:1},8,["label"]),g("",!0)]),_:1},8,["model"])}}});export{ge as default};
