import{_ as a}from"./index.vue_vue_type_script_setup_true_lang.js?v=1753954525509";import{b1 as e,er as s,o as l,m as t}from"./page_layout.js?v=1753954525509";import{_ as r}from"./index.vue_vue_type_script_setup_true_lang2.js?v=1753954525509";import{k as d,P as o,$ as i,r as n,e as u,c as p,U as c,a1 as m,a2 as b,Q as _,W as v,X as f,al as x,j as g,a3 as h,N as w}from"./vue.js?v=1753954525509";import"./public.js?v=1753954525509";import{g as D}from"./index126.js?v=1753954525509";import{aq as j,cG as $,cA as y,c5 as U}from"./naive.js?v=1753954525509";import"./common.js?v=1753954525509";import"./__commonjsHelpers__.js?v=1753954525509";import"./index96.js?v=1753954525509";import"./index127.js?v=1753954525509";import"./soft.js?v=1753954525509";const k={class:"w-240px"},A={class:"w-100px ml-8px"},R={class:"w-240px"},q={class:"w-240px"},E={class:"w-240px"},L={class:"w-240px"},Q={class:"w-240px"},S={class:"ml-8px"},C=d({__name:"index",setup(d,{expose:C}){const{t:z}=o(),G=e(),{remoteList:H}=i(G),I=n(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=n([{label:"utf-8",value:"utf8"},{label:"utf8mb4",value:"utf8mb4"},{label:"gbk",value:"gbk"},{label:"big5",value:"big5"}]),P=n([{label:z("Database.form.index_12"),value:"127.0.0.1"},{label:z("Database.form.index_13"),value:"%"},{label:z("Database.form.index_14"),value:"ip"}]),W=p((()=>H.value.map((a=>({label:"".concat(a.ps," (").concat(a.db_host,")"),value:a.id}))))),X={name:{required:!0,message:z("Database.form.index_15"),trigger:["blur","change"]},db_user:{required:!0,message:z("Database.form.index_16"),trigger:["blur","change"]},password:{required:!0,message:z("Database.form.index_17"),trigger:["blur","change"]},sid:{trigger:"change",validator:(a,e)=>null!==e||new Error(z("Database.form.index_18"))}},B=a=>{M.db_user=a},F=a=>{M.address="ip"===a?"":a},J=a=>{M.ssl=a?"REQUIRE SSL":""},K=()=>{D()};return C({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(z("Database.form.index_18")),new Error(z("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 s(a),G.setRefresh(!0)}catch(e){console.warn(e)}}}),(e,s)=>{const t=j,d=$,o=y,i=r,n=l,u=U,p=a;return c(),m(p,{ref_key:"formRef",ref:I,model:f(M),rules:X,class:"p-20px"},{default:b((()=>[_(o,{label:e.$t("Database.form.index_1"),path:"name"},{default:b((()=>[v("div",k,[_(t,{value:f(M).name,"onUpdate:value":[s[0]||(s[0]=a=>f(M).name=a),B],placeholder:e.$t("Database.form.index_2"),"input-props":{name:"name"}},null,8,["value","placeholder"])]),v("div",A,[_(d,{value:f(M).codeing,"onUpdate:value":s[1]||(s[1]=a=>f(M).codeing=a),class:"code-select",options:f(N)},null,8,["value","options"])])])),_:1},8,["label"]),_(o,{label:e.$t("Database.form.index_3"),path:"db_user"},{default:b((()=>[v("div",R,[_(t,{value:f(M).db_user,"onUpdate:value":s[2]||(s[2]=a=>f(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((()=>[v("div",q,[_(i,{value:f(M).password,"onUpdate:value":s[3]||(s[3]=a=>f(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((()=>[v("div",E,[_(d,{value:f(M).dataAccess,"onUpdate:value":[s[4]||(s[4]=a=>f(M).dataAccess=a),F],class:"access-select",options:f(P)},null,8,["value","options"])])])),_:1},8,["label"]),"ip"===f(M).dataAccess?(c(),m(o,{key:0,label:e.$t("Database.form.index_7"),path:"address"},{default:b((()=>[v("div",L,[_(t,{value:f(M).address,"onUpdate:value":s[5]||(s[5]=a=>f(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"])):x("",!0),_(o,{label:e.$t("Database.form.index_9"),path:"sid"},{default:b((()=>[v("div",Q,[_(d,{value:f(M).sid,"onUpdate:value":s[6]||(s[6]=a=>f(M).sid=a),class:"sid-select",options:f(W)},null,8,["value","options"])]),v("div",S,[_(n,{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:f(M).active,"onUpdate:value":[s[7]||(s[7]=a=>f(M).active=a),J],class:"ssl-switch"},null,8,["value"])])),_:1},8,["label"])])),_:1},8,["model"])}}});export{C as default};
