import{K as e,bw as a,bq as l,ax as t,c5 as r,k as o,$ as d}from"./utils-lib.js?v=1761009159";import{c as s,g as i,e as u,q as m,v as n,N as p,B as c,z as h,y as b,C as v,x as y,b0 as f,F as g,G as V,al as _,ab as U,ak as j}from"./base-lib.js?v=1761009159";import{r as w,l as k,m as x,n as C,o as L}from"./useController18.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./site.js?v=1761009159";import"./column.js?v=1761009159";import"./index106.js?v=1761009159";import"./useStore4.js?v=1761009159";const R={class:"flex items-center"},q={class:"flex items-center justify-center checked-button"},B=s({__name:"add-redirect",setup(s,{expose:B}){const E=e=>{G.value.redirectdomain=C.value.map(e=>e.name)},F=e=>{G.value.redirectdomain=[]},{BtForm:z,param:G,submit:H}=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=>i(()=>[{type:"custom",render:()=>u(l,{label:"开启重定向"},{default:()=>[u("div",{class:"flex items-center"},[u(a,{modelValue:e.value.type,"onUpdate:modelValue":a=>e.value.type=a},null),u(l,{label:"保留URL参数",style:"margin-left: 4rem;"},{default:()=>[u(a,{modelValue:e.value.holdpath,"onUpdate:modelValue":a=>e.value.holdpath=a},null)]})])]})},{type:"custom",render:()=>u(l,{label:"重定向类型"},{default:()=>[u("div",{class:"flex items-center"},[u(t,{modelValue:e.value.domainorpath,"onUpdate:modelValue":a=>e.value.domainorpath=a,options:[{label:"域名",value:"domain"},{label:"路径",value:"path"}],style:"width: 15rem;"},null),u(l,{label:"重定向方式"},{default:()=>[u(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"}],redirectpath:[{required:!0,message:"请输入重定向路径",trigger:"blur"}]}}]),submit:async(e,a)=>(await a(),await k(e.value))});return m(x),B({onConfirm:H}),(e,a)=>{const l=V,t=j,r=_,s=o,i=U,m=d;return n(),p(b(z),{class:"p-[2rem]"},{domain:c(()=>[u(i,{prop:"domain"===b(G).domainorpath?"redirectdomain":"redirectpath",label:"重定向".concat("domain"===b(G).domainorpath?"域名":"路径")},{default:c(()=>[h("div",R,["domain"===b(G).domainorpath?(n(),p(r,{key:0,"collapse-tags":"",multiple:"",style:{width:"15rem"},modelValue:b(G).redirectdomain,"onUpdate:modelValue":a[0]||(a[0]=e=>b(G).redirectdomain=e)},{header:c(()=>[h("div",q,[u(l,{onClick:E,type:"default"},{default:c(()=>a[3]||(a[3]=[v("全选",-1)])),_:1,__:[3]}),u(l,{onClick:F,type:"default"},{default:c(()=>a[4]||(a[4]=[v("取消全选",-1)])),_:1,__:[4]})])]),default:c(()=>[(n(!0),y(g,null,f(b(C),(e,a)=>(n(),p(t,{key:a,value:e.name,label:e.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])):(n(),p(s,{key:1,width:"15rem",modelValue:b(G).redirectpath,"onUpdate:modelValue":a[1]||(a[1]=e=>b(G).redirectpath=e),placeholder:"如：/b.com"},null,8,["modelValue"])),u(i,{label:"目标url",prop:"tourl"},{default:c(()=>[u(s,{modelValue:b(G).tourl,"onUpdate:modelValue":a[2]||(a[2]=e=>b(G).tourl=e),width:"24rem"},null,8,["modelValue"])]),_:1})])]),_:1},8,["prop","label"]),u(i,null,{default:c(()=>[u(m,{options:b(L),"list-style":"disc"},null,8,["options"])]),_:1})]),_:1})}}});export{B as default};
