← Back
Editing: add-redirect.js
import{G as e,dG as a,bg as l,ag as t,bU as r,j as o,W as i}from"./utils-lib.js?v=1765440387";import{c as d,g as s,e as m,p as n,q as u,M as p,A as c,x as h,y as v,B as f,v as y,F as b,a$ as g,D as j,aj as V,ak as x,aa as U}from"./base-lib.js?v=1765440387";import{I as _,J as w,K as k,L as C,M as L}from"./index192.js?v=1765440387";import"./__commonjsHelpers__.js?v=1765440387";import"./useController4.js?v=1765440387";import"./validator.js?v=1765440387";import"./index94.js?v=1765440387";import"./column.js?v=1765440387";import"./useController5.js?v=1765440387";import"./site.js?v=1765440387";import"./useStore3.js?v=1765440387";import"./useController6.js?v=1765440387";import"./index93.js?v=1765440387";import"./index395.js?v=1765440387";import"./form-item.js?v=1765440387";import"./index130.js?v=1765440387";import"./ace.js?v=1765440387";import"./index106.js?v=1765440387";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:G,param:M,submit:A,clearValidate:D}=e({data:()=>{let e={type:!0,holdpath:!0,domainorpath:"domain",redirecttype:"301",redirectpath:"",tourl:"http://",redirectdomain:[],redirectname:""};if(_.value){const{type:a,holdpath:l,...t}=_.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=>{D()},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 w(e.value))});return n(k),E({onConfirm:A}),(e,a)=>{const l=j,t=V,r=x,d=o,s=U,n=i;return u(),p(h(G),{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]=[f("全选",-1)])]),_:1}),m(l,{onClick:F,type:"default"},{default:c(()=>[...a[4]||(a[4]=[f("取消全选",-1)])]),_:1})])]),default:c(()=>[(u(!0),y(b,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};
Save File
Cancel