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