File: /www/server/panel/BTPanel/static/js/add-redirect.js
import{X as k,d_ as h,B as i,W as v,cN as E,cO as L,cP as R}from"./utils-lib.js?v=1777008528";import{c as A,g as N,e as t,o as O,j as s,C as m,v as u,q as y,p as a,x as f,k as j,B as q,F as I,z as $,am as z,an as D,ad as H}from"./base-lib.js?v=1777008528";import{r as g,l as M,m as P,n as b,o as S}from"./useController16.js?v=1777008528";import"./__commonjsHelpers__.js?v=1777008528";import"./site.js?v=1777008528";import"./index3.js?v=1777008528";import"./index119.js?v=1777008528";import"./index116.js?v=1777008528";import"./useStore2.js?v=1777008528";const T={class:"flex items-center"},W={class:"flex items-center justify-center checked-button"},ae=A({__name:"add-redirect",setup(X,{expose:V}){const B=l=>{o.value.redirectdomain=b.value.map(e=>e.name)},w=l=>{o.value.redirectdomain=[]},{BtForm:x,param:o,submit:U}=k({data:()=>{let l={type:!0,holdpath:!0,domainorpath:"domain",redirecttype:"301",redirectpath:"",tourl:"http://",redirectdomain:[],redirectname:""};if(g.value){const{type:e,holdpath:r,...d}=g.value;Object.assign(l,{type:e===1,holdpath:r===1,...d})}return l},options:l=>N(()=>[{type:"custom",render:()=>t(i,{label:"开启重定向"},{default:()=>[t("div",{class:"flex items-center"},[t(h,{modelValue:l.value.type,"onUpdate:modelValue":e=>l.value.type=e},null),t(i,{label:"保留URL参数",style:"margin-left: 4rem;"},{default:()=>[t(h,{modelValue:l.value.holdpath,"onUpdate:modelValue":e=>l.value.holdpath=e},null)]})])]})},{type:"custom",render:()=>t(i,{label:"重定向类型"},{default:()=>[t("div",{class:"flex items-center"},[t(v,{modelValue:l.value.domainorpath,"onUpdate:modelValue":e=>l.value.domainorpath=e,options:[{label:"域名",value:"domain"},{label:"路径",value:"path"}],style:"width: 15rem;"},null),t(i,{label:"重定向方式"},{default:()=>[t(v,{modelValue:l.value.redirecttype,"onUpdate:modelValue":e=>l.value.redirecttype=e,options:[{label:"301(永久重定向)",value:"301"},{label:"302(临时重定向)",value:"302"}],style:"width: 15rem;"},null)]})])]})},{type:"slots",key:"domain",rules:{tourl:[E({message:"请输入目标URL",trigger:"blur"}),{validator:(e,r,d)=>{if(r==="http://"||r==="https://")d(new Error("请输入目标URL"));else try{new URL(r),d()}catch(c){d(new Error("请输入正确的URL"))}},trigger:["change","input"]}],redirectdomain:[{required:!0,message:"请选择重定向域名",trigger:"change"}],redirectpath:[{required:!0,message:"请输入重定向路径",trigger:"blur"}]}}]),submit:async(l,e)=>(await e(),await M(l.value))});return O(P),V({onConfirm:U}),(l,e)=>{const r=$,d=z,c=D,_=L,p=H,C=R;return s(),m(a(x),{class:"p-[2rem]"},{domain:u(()=>[t(p,{prop:a(o).domainorpath==="domain"?"redirectdomain":"redirectpath",label:"重定向".concat(a(o).domainorpath==="domain"?"域名":"路径")},{default:u(()=>[y("div",T,[a(o).domainorpath==="domain"?(s(),m(c,{key:0,"popper-class":"!max-w-max","collapse-tags":"",multiple:"",style:{width:"15rem"},modelValue:a(o).redirectdomain,"onUpdate:modelValue":e[0]||(e[0]=n=>a(o).redirectdomain=n)},{header:u(()=>[y("div",W,[t(r,{onClick:B,type:"default"},{default:u(()=>[...e[3]||(e[3]=[f("全选",-1)])]),_:1}),t(r,{onClick:w,type:"default"},{default:u(()=>[...e[4]||(e[4]=[f("取消全选",-1)])]),_:1})])]),default:u(()=>[(s(!0),j(I,null,q(a(b),(n,F)=>(s(),m(d,{key:F,value:n.name,label:n.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])):(s(),m(_,{key:1,width:"15rem",modelValue:a(o).redirectpath,"onUpdate:modelValue":e[1]||(e[1]=n=>a(o).redirectpath=n),placeholder:"如:/b.com"},null,8,["modelValue"])),t(p,{label:"目标url",prop:"tourl"},{default:u(()=>[t(_,{modelValue:a(o).tourl,"onUpdate:modelValue":e[2]||(e[2]=n=>a(o).tourl=n),width:"24rem"},null,8,["modelValue"])]),_:1})])]),_:1},8,["prop","label"]),t(p,null,{default:u(()=>[t(C,{options:a(S),"list-style":"disc"},null,8,["options"])]),_:1})]),_:1})}}});export{ae as default};