2 lines
8.4 KiB
JavaScript
2 lines
8.4 KiB
JavaScript
import{aj as t,u as P,r as a,F as s,j as i,D as r,T as b,a as T,C as m,I as j,B as k,bb as I,w as p}from"./index-B-sDl1ER.js";import{X as q}from"./index-duCmqVUU.js";import{C as c}from"./index-CO5DzGxy.js";import"./index-BZjcF0yn.js";import"./tslib.es6-BaFViOhq.js";import"./index-D3yl9SWR.js";import"./progress-C__thZ4V.js";import"./index-C9m5qSM4.js";import"./Table-B11dzOaz.js";import"./index-CeRfFUxJ.js";import"./index-DmtjhyJb.js";async function F(){return t({url:"/system/mail/config",method:"get"})}async function R(l){return t({url:"/system/mail/save",method:"post",data:l})}async function w(l){return t({url:"/system/mail/test",method:"post",data:{to:l}})}const{Text:C,Title:S}=b,G=()=>{const{t:l}=P(),u=a.useRef(null),[n]=s.useForm(),[h]=s.useForm(),[f,d]=a.useState(!1),o=[{label:l("mail.driver.smtp"),value:"smtp"},{label:l("mail.driver.ses"),value:"ses"},{label:l("mail.driver.mailgun"),value:"mailgun"},{label:l("mail.driver.postmark"),value:"postmark"},{label:l("mail.driver.resend"),value:"resend"},{label:l("mail.driver.log"),value:"log"},{label:l("mail.driver.array"),value:"array"}],y=[{dataIndex:["other","mode"],valueType:"radio",title:l("mail.mode"),fieldProps:{options:[{label:l("mail.mode.single"),value:"single"},{label:l("mail.mode.failover"),value:"failover"},{label:l("mail.mode.roundrobin"),value:"roundrobin"}]},required:!0,colProps:{span:24}},{dataIndex:["mail","default"],valueType:"radioButton",title:l("mail.driver"),fieldProps:{options:o},required:!0,colProps:{span:24},dependency:{dependencies:["other"],visible:e=>e.other?.mode==="single"}},{dataIndex:["other","mailers"],valueType:"checkbox",title:l("mail.driver"),fieldProps:{options:o},colProps:{span:24},dependency:{dependencies:["other"],visible:e=>e.other?.mode!=="single"}},{dataIndex:["mail","from","address"],valueType:"text",title:l("mail.from_address"),fieldProps:{placeholder:l("mail.from_address.placeholder")},required:!0,colProps:{span:12}},{dataIndex:["mail","from","name"],valueType:"text",title:l("mail.from_name"),fieldProps:{placeholder:l("mail.from_name.placeholder")},required:!0,colProps:{span:12}},{fieldRender:()=>i.jsx(r,{children:l("mail.smtp.title")}),dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="smtp"||!!e.other?.mailers?.includes("smtp")},colProps:{span:24},noStyle:!0},{dataIndex:["mail","mailers","smtp","host"],valueType:"text",title:l("mail.host"),fieldProps:{placeholder:l("mail.host.placeholder")},required:!0,colProps:{span:16},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="smtp"||!!e.other?.mailers?.includes("smtp")}},{dataIndex:["mail","mailers","smtp","port"],valueType:"digit",title:l("mail.port"),fieldProps:{placeholder:l("mail.port.placeholder")},required:!0,colProps:{span:8},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="smtp"||!!e.other?.mailers?.includes("smtp")}},{dataIndex:["mail","mailers","smtp","username"],valueType:"text",title:l("mail.username"),fieldProps:{placeholder:l("mail.username.placeholder")},required:!0,colProps:{span:12},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="smtp"||!!e.other?.mailers?.includes("smtp")}},{dataIndex:["mail","mailers","smtp","password"],valueType:"password",title:l("mail.password"),fieldProps:{placeholder:l("mail.password.placeholder")},required:!0,colProps:{span:12},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="smtp"||!!e.other?.mailers?.includes("smtp")}},{fieldRender:()=>i.jsx(r,{children:l("mail.log.title")}),dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="log"||!!e.other?.mailers?.includes("log")},colProps:{span:24},noStyle:!0},{dataIndex:["mail","mailers","log","channel"],valueType:"text",title:l("mail.log.channel"),fieldProps:{placeholder:l("mail.log.channel.placeholder")},required:!0,colProps:{span:24},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="log"||!!e.other?.mailers?.includes("log")}},{fieldRender:()=>i.jsx(r,{children:l("mail.postmark.title")}),dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="postmark"||!!e.other?.mailers?.includes("postmark")},colProps:{span:24},noStyle:!0},{dataIndex:["services","postmark","token"],valueType:"text",title:l("mail.postmark.token"),fieldProps:{placeholder:l("mail.postmark.token.placeholder")},required:!0,colProps:{span:24},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="postmark"||!!e.other?.mailers?.includes("postmark")}},{fieldRender:()=>i.jsx(r,{children:l("mail.resend.title")}),dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="resend"||!!e.other?.mailers?.includes("resend")},colProps:{span:24},noStyle:!0},{dataIndex:["services","resend","key"],valueType:"text",title:l("mail.resend.key"),fieldProps:{placeholder:l("mail.resend.key.placeholder")},required:!0,colProps:{span:24},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="resend"||!!e.other?.mailers?.includes("resend")}},{fieldRender:()=>i.jsx(r,{children:l("mail.mailgun.title")}),dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="mailgun"||!!e.other?.mailers?.includes("mailgun")},colProps:{span:24},noStyle:!0},{dataIndex:["services","mailgun","domain"],valueType:"text",title:l("mail.mailgun.domain"),fieldProps:{placeholder:l("mail.mailgun.domain.placeholder")},required:!0,colProps:{span:12},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="mailgun"||!!e.other?.mailers?.includes("mailgun")}},{dataIndex:["services","mailgun","secret"],valueType:"text",title:l("mail.mailgun.secret"),fieldProps:{placeholder:l("mail.mailgun.secret.placeholder")},required:!0,colProps:{span:12},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="mailgun"||!!e.other?.mailers?.includes("mailgun")}},{dataIndex:["services","mailgun","endpoint"],valueType:"text",title:l("mail.mailgun.endpoint"),fieldProps:{placeholder:l("mail.mailgun.endpoint.placeholder")},required:!0,colProps:{span:12},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="mailgun"||!!e.other?.mailers?.includes("mailgun")}},{fieldRender:()=>i.jsx(r,{children:l("mail.ses.title")}),dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="ses"||!!e.other?.mailers?.includes("ses")},colProps:{span:24},noStyle:!0},{dataIndex:["services","ses","key"],valueType:"text",title:l("mail.ses.key"),fieldProps:{placeholder:l("mail.ses.key.placeholder")},required:!0,colProps:{span:12},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="ses"||!!e.other?.mailers?.includes("ses")}},{dataIndex:["services","ses","secret"],valueType:"text",title:l("mail.ses.secret"),fieldProps:{placeholder:l("mail.ses.secret.placeholder")},required:!0,colProps:{span:12},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="ses"||!!e.other?.mailers?.includes("ses")}},{dataIndex:["services","ses","region"],valueType:"text",title:l("mail.ses.region"),fieldProps:{placeholder:l("mail.ses.region.placeholder")},required:!0,colProps:{span:12},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="ses"||!!e.other?.mailers?.includes("ses")}},{dataIndex:["services","ses","token"],valueType:"text",title:l("mail.ses.token"),fieldProps:{placeholder:l("mail.ses.token.placeholder")},required:!0,colProps:{span:12},dependency:{dependencies:["mail","other"],visible:e=>e.mail?.default==="ses"||!!e.other?.mailers?.includes("ses")}}];a.useEffect(()=>{v()},[]);const v=async()=>{const{data:e}=await F();e.success&&n.setFieldsValue(e.data)},x=async e=>{await R(e),p.success(l("mail.save.success"))},g=async e=>{try{d(!0),await w(e.to),p.success(l("mail.test.success"))}finally{d(!1)}};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-5",children:[i.jsx(S,{level:3,children:l("mail.page.title")}),i.jsx(C,{type:"secondary",children:l("mail.page.description")})]}),i.jsxs(T,{gutter:24,children:[i.jsx(m,{span:16,children:i.jsx(c,{variant:"borderless",children:i.jsx(q,{columns:y,layout:"vertical",formRef:u,form:n,grid:!0,onFinish:x,rowProps:{gutter:[10,0]}})})}),i.jsx(m,{span:8,children:i.jsx(c,{title:l("mail.test.title"),children:i.jsxs(s,{form:h,layout:"vertical",onFinish:g,children:[i.jsx(s.Item,{name:"to",label:l("mail.test.to"),rules:[{required:!0,type:"email"}],children:i.jsx(j,{placeholder:l("mail.test.to.placeholder")})}),i.jsx(k,{type:"primary",htmlType:"submit",block:!0,icon:i.jsx(I,{}),loading:f,children:l("mail.test.send")})]})})})]})]})};export{G as default};
|