import{_ as a}from"./index.vue_vue_type_script_setup_true_lang.js?v=1764233927359";import{bn as e,o as s,fn as l,m as t}from"./page_layout.js?v=1764233927359";import{_ as r}from"./index.vue_vue_type_script_setup_true_lang2.js?v=1764233927359";import{k as d,P as o,a0 as n,r as i,e as u,c as p,a2 as m,V as c,a3 as b,W as _,an as v,S as f,U as x,j as g,a4 as h,N as w}from"./vue.js?v=1764233927359";import"./public.js?v=1764233927359";import{g as D}from"./index131.js?v=1764233927359";import{dR as j,au as $,dV as y,dj as U}from"./naive.js?v=1764233927359";import"./common.js?v=1764233927359";import"./__commonjsHelpers__.js?v=1764233927359";import"./index98.js?v=1764233927359";import"./index132.js?v=1764233927359";import"./soft.js?v=1764233927359";import"./site.js?v=1764233927359";const k={class:"w-240px"},R={class:"w-100px ml-8px"},A={class:"w-240px"},E={class:"w-240px"},S={class:"w-240px"},q={class:"w-240px"},L={class:"w-240px"},C={class:"ml-8px"},Q=d({__name:"index",setup(d,{expose:Q}){const{t:V}=o(),z=e(),{remoteList:H}=n(z),I=i(null),M=u({sid:H.value.length>0?H.value[0].id:null,name:"",codeing:"utf8",db_user:"",password:"",dataAccess:"127.0.0.1",address:"127.0.0.1",active:!1,ssl:""}),N=i([{label:"utf-8",value:"utf8"},{label:"utf8mb4",value:"utf8mb4"},{label:"gbk",value:"gbk"},{label:"big5",value:"big5"}]),P=i([{label:V("Database.form.index_12"),value:"127.0.0.1"},{label:V("Database.form.index_13"),value:"%"},{label:V("Database.form.index_14"),value:"ip"}]),W=p(()=>H.value.map(a=>({label:"".concat(a.ps," (").concat(a.db_host,")"),value:a.id}))),B={name:{required:!0,message:V("Database.form.index_15"),trigger:["blur","change"]},db_user:{required:!0,message:V("Database.form.index_16"),trigger:["blur","change"]},password:{required:!0,message:V("Database.form.index_17"),trigger:["blur","change"]},sid:{trigger:"change",validator:(a,e)=>null!==e||new Error(V("Database.form.index_18"))}},F=a=>{M.db_user=a},G=a=>{M.address="ip"===a?"":a},J=a=>{M.ssl=a?"REQUIRE SSL":""},K=()=>{D()};return Q({onConfirm:async()=>{var a;await(null==(a=I.value)?void 0:a.validate());try{const a=(()=>{const a=w(M),{sid:e}=a;if(null===e)throw t.error(V("Database.form.index_18")),new Error(V("Database.form.index_18"));return{...a,sid:e,ps:a.name,dtype:"MySQL",address:"ip"===M.dataAccess?M.address.trim().split("\n").join(","):M.address}})();await l(a),z.setRefresh(!0)}catch(e){console.warn(e)}}}),(e,l)=>{const t=$,d=y,o=j,n=r,i=s,u=U,p=a;return c(),m(p,{ref_key:"formRef",ref:I,model:x(M),rules:B,class:"p-20px"},{default:b(()=>[_(o,{label:e.$t("Database.form.index_1"),path:"name"},{default:b(()=>[f("div",k,[_(t,{value:x(M).name,"onUpdate:value":[l[0]||(l[0]=a=>x(M).name=a),F],placeholder:e.$t("Database.form.index_2"),"input-props":{name:"name"}},null,8,["value","placeholder"])]),f("div",R,[_(d,{value:x(M).codeing,"onUpdate:value":l[1]||(l[1]=a=>x(M).codeing=a),class:"code-select",options:x(N)},null,8,["value","options"])])]),_:1},8,["label"]),_(o,{label:e.$t("Database.form.index_3"),path:"db_user"},{default:b(()=>[f("div",A,[_(t,{value:x(M).db_user,"onUpdate:value":l[2]||(l[2]=a=>x(M).db_user=a),placeholder:e.$t("Database.form.index_4"),"input-props":{name:"username"}},null,8,["value","placeholder"])])]),_:1},8,["label"]),_(o,{label:e.$t("Database.form.index_5"),path:"password"},{default:b(()=>[f("div",E,[_(n,{value:x(M).password,"onUpdate:value":l[3]||(l[3]=a=>x(M).password=a),placeholder:"","input-props":{name:"password"}},null,8,["value"])])]),_:1},8,["label"]),_(o,{label:e.$t("Database.form.index_6"),path:"dataAccess"},{default:b(()=>[f("div",S,[_(d,{value:x(M).dataAccess,"onUpdate:value":[l[4]||(l[4]=a=>x(M).dataAccess=a),G],class:"access-select",options:x(P)},null,8,["value","options"])])]),_:1},8,["label"]),"ip"===x(M).dataAccess?(c(),m(o,{key:0,label:e.$t("Database.form.index_7"),path:"address"},{default:b(()=>[f("div",q,[_(t,{value:x(M).address,"onUpdate:value":l[5]||(l[5]=a=>x(M).address=a),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"])):v("",!0),_(o,{label:e.$t("Database.form.index_9"),path:"sid"},{default:b(()=>[f("div",L,[_(d,{value:x(M).sid,"onUpdate:value":l[6]||(l[6]=a=>x(M).sid=a),class:"sid-select",options:x(W)},null,8,["value","options"])]),f("div",C,[_(i,{onClick:K},{default:b(()=>[g(h(e.$t("Database.form.index_10")),1)]),_:1})])]),_:1},8,["label"]),_(o,{label:e.$t("Database.form.index_11"),"show-feedback":!1},{default:b(()=>[_(u,{value:x(M).active,"onUpdate:value":[l[7]||(l[7]=a=>x(M).active=a),J],class:"ssl-switch"},null,8,["value"])]),_:1},8,["label"])]),_:1},8,["model"])}}});export{Q as default};
