import{K as e,bw as a,bq as l,ax as t,c5 as r,k as o,$ as i}from"./utils-lib.js?v=1761009159";import{c as d,g as s,e as m,q as n,v as u,N as p,B as c,y as h,z as v,C as b,x as f,F as y,b0 as g,G as j,ak as V,al as _,ab as x}from"./base-lib.js?v=1761009159";import{I as w,J as U,K as k,L as C,M as L}from"./index200.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./useController4.js?v=1761009159";import"./validator.js?v=1761009159";import"./index106.js?v=1761009159";import"./column.js?v=1761009159";import"./useController5.js?v=1761009159";import"./site.js?v=1761009159";import"./useStore4.js?v=1761009159";import"./useController6.js?v=1761009159";import"./useMethod5.js?v=1761009159";import"./index105.js?v=1761009159";import"./index420.js?v=1761009159";import"./form-item.js?v=1761009159";import"./index115.js?v=1761009159";import"./ace.js?v=1761009159";import"./index119.js?v=1761009159";const R={class:"flex items-center"},q={class:"flex items-center justify-center checked-button"},E=d({__name:"add-redirect",setup(d,{expose:E}){const B=e=>{M.value.redirectdomain=C.value.map(e=>e.name)},F=e=>{M.value.redirectdomain=[]},{BtForm:K,param:M,submit:z,clearValidate:G}=e({data:()=>{let e={type:!0,holdpath:!0,domainorpath:"domain",redirecttype:"301",redirectpath:"",tourl:"http://",redirectdomain:[],redirectname:""};if(w.value){const{type:a,holdpath:l,...t}=w.value;Object.assign(e,{type:1===a,holdpath:1===l,...t})}return e},options:e=>s(()=>[{type:"custom",render:()=>m(l,{label:"开启重定向"},{default:()=>[m("div",{class:"flex items-center"},[m(a,{modelValue:e.value.type,"onUpdate:modelValue":a=>e.value.type=a},null),m(l,{label:"保留URL参数",style:"margin-left: 4rem;"},{default:()=>[m(a,{modelValue:e.value.holdpath,"onUpdate:modelValue":a=>e.value.holdpath=a},null)]})])]})},{type:"custom",render:()=>m(l,{label:"重定向类型"},{default:()=>[m("div",{class:"flex items-center"},[m(t,{modelValue:e.value.domainorpath,"onUpdate:modelValue":a=>e.value.domainorpath=a,options:[{label:"域名",value:"domain"},{label:"路径",value:"path"}],onChange:e=>{G()},style:"width: 15rem;"},null),m(l,{label:"重定向方式"},{default:()=>[m(t,{modelValue:e.value.redirecttype,"onUpdate:modelValue":a=>e.value.redirecttype=a,options:[{label:"301（永久重定向）",value:"301"},{label:"302（临时重定向）",value:"302"}],style:"width: 15rem;"},null)]})])]})},{type:"slots",key:"domain",rules:{tourl:[r({message:"请输入目标URL",trigger:"blur"}),{validator:(e,a,l)=>{if("http://"===a||"https://"===a)l(new Error("请输入目标URL"));else try{new URL(a),l()}catch(t){l(new Error("请输入正确的URL"))}},trigger:["change","input"]}],redirectdomain:[{required:!0,message:"请选择重定向域名",trigger:"change"},{validator:(a,l,t)=>{0===l.length&&"domain"===e.value.domainorpath?t(new Error("请选择重定向域名")):t()},trigger:["change"]}],redirectpath:[{required:!0,message:"请输入重定向路径",trigger:"blur"}]}}]),submit:async(e,a)=>(await a(),await U(e.value))});return n(k),E({onConfirm:z}),(e,a)=>{const l=j,t=V,r=_,d=o,s=x,n=i;return u(),p(h(K),{class:"p-[2rem]"},{domain:c(()=>[m(s,{prop:"domain"===h(M).domainorpath?"redirectdomain":"redirectpath",label:"重定向".concat("domain"===h(M).domainorpath?"域名":"路径")},{default:c(()=>[v("div",R,["domain"===h(M).domainorpath?(u(),p(r,{key:0,"collapse-tags":"",multiple:"",style:{width:"15rem"},modelValue:h(M).redirectdomain,"onUpdate:modelValue":a[0]||(a[0]=e=>h(M).redirectdomain=e)},{header:c(()=>[v("div",q,[m(l,{onClick:B,type:"default"},{default:c(()=>a[3]||(a[3]=[b("全选",-1)])),_:1,__:[3]}),m(l,{onClick:F,type:"default"},{default:c(()=>a[4]||(a[4]=[b("取消全选",-1)])),_:1,__:[4]})])]),default:c(()=>[(u(!0),f(y,null,g(h(C),(e,a)=>(u(),p(t,{key:a,value:e.name,label:e.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])):(u(),p(d,{key:1,width:"15rem",modelValue:h(M).redirectpath,"onUpdate:modelValue":a[1]||(a[1]=e=>h(M).redirectpath=e),placeholder:"如：/b.com"},null,8,["modelValue"])),m(s,{label:"目标url",prop:"tourl"},{default:c(()=>[m(d,{modelValue:h(M).tourl,"onUpdate:modelValue":a[2]||(a[2]=e=>h(M).tourl=e),width:"24rem"},null,8,["modelValue"])]),_:1})])]),_:1},8,["prop","label"]),m(s,null,{default:c(()=>[m(n,{options:h(L),"list-style":"disc"},null,8,["options"])]),_:1})]),_:1})}}});export{E as default};
