2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
import{c as G,ao as ne,n as q,l as le,m as pe}from"./index-BTglIPU2.js?v=1773287522785";import{c as fe}from"./copy-D-wIKr0q.js?v=1773287522785";import{u as te,e as _e,a as ve}from"./custom-W85Jyu3e.js?v=1773287522785";import{aH as ae,B as Y,a6 as I,a1 as ie,o as re,b as ce,p as N,a7 as me}from"./naive-ui--dJnpVcV.js?v=1773287522785";import{k as J,an as Z,r as X,$ as g,a8 as D,a9 as y,a0 as p,j as T,aa as F,s as K,S as d,R as ue,c as P,Z as E,F as Q,_ as v,l as he,v as ge,ak as H,au as we,ao as de,P as oe,ay as ee,t as be,e as ye,X as xe,n as $e}from"./vue-core-DJjvd5ZC.js?v=1773287522785";import"./prismjs-BZPoR7_J.js?v=1773287522785";const Ce=J({__name:"site-select",props:{value:{},valueModifiers:{}},emits:["update:value"],setup(x){const f=Z(x,"value"),k=te(),o=X([]),$=()=>{f.value=o.value.map(n=>n.value)},S=()=>{f.value=[]};return(async()=>o.value=Object.entries(k.config.sitemap).map(([n,O])=>({label:n,value:O})))(),(n,O)=>{const w=Y,j=ae,m=I;return g(),D(m,K(n.$attrs,{value:f.value,"onUpdate:value":O[0]||(O[0]=h=>f.value=h),multiple:"",filterable:"",options:d(o),"max-tag-count":"responsive","consistent-menu-width":!1,placeholder:n.$t("Waf.Custom.index_25")}),{header:y(()=>[p(j,{class:"w-full"},{default:y(()=>[p(w,{class:"flex-1",onClick:$},{default:y(()=>[T(F(n.$t("Public.All")),1)]),_:1}),p(w,{class:"flex-1",onClick:S},{default:y(()=>[T(F(n.$t("Public.Btn.Cancel")),1)]),_:1})]),_:1})]),_:1},16,["value","options","placeholder"])}}}),Fe={class:"w-320px"},ke={class:"w-320px"},Ue=J({__name:"action",props:{action:{default:""},actionModifiers:{},response:{},responseModifiers:{}},emits:["update:action","update:response"],setup(x){const{t:f}=ue(),k=te(),o=Z(x,"action"),$=Z(x,"response"),S=X([]),U=P(()=>{let m="";switch(o.value){case"deny":m=f("Waf.Custom.index_21");break;case"validate":m=f("Waf.Custom.index_32");break}return m}),n=P(()=>O(o.value).map(h=>({label:h.text,value:h.type,data:h}))),O=m=>{const h=k.config.action.filter(W=>W.type===m);return h.length>0?h[0].response:[]},w=m=>{const h=O(m);h.length>0?$.value=h[0].type:$.value=null};return S.value=k.config.action.map(m=>({label:m.text,value:m.type,data:m})),$.value===null&&w(o.value),(m,h)=>{const W=I,A=ie;return g(),E(Q,null,[p(A,{label:m.$t("Waf.Custom.index_20")},{default:y(()=>[v("div",Fe,[p(W,{value:o.value,"onUpdate:value":[h[0]||(h[0]=M=>o.value=M),w],options:d(S)},null,8,["value","options"])])]),_:1},8,["label"]),he(p(A,{label:d(U),"show-feedback":!1},{default:y(()=>[v("div",ke,[p(W,{value:$.value,"onUpdate:value":h[1]||(h[1]=M=>$.value=M),options:d(n)},null,8,["value","options"])])]),_:1},8,["label"]),[[ge,d(n).length>0]])],64)}}}),We={},Re={class:"my-18px"};function Oe(x,f){const k=re;return g(),E("div",Re,[p(k,{class:"w-38px justify-center"},{default:y(()=>[T(F(x.$t("Waf.Custom.index_31")),1)]),_:1})])}const Se=G(We,[["render",Oe]]),Le={},Ee={class:"flex flex-center flex-col w-38px"};function Be(x,f){const k=re;return g(),E("div",Ee,[f[0]||(f[0]=v("div",{class:"seg"},null,-1)),p(k,{class:"w-38px justify-center"},{default:y(()=>[T(F(x.$t("Waf.Custom.index_30")),1)]),_:1}),f[1]||(f[1]=v("div",{class:"seg"},null,-1))])}const Me=G(Le,[["render",Be],["__scopeId","data-v-7ea28fa1"]]),je={class:"relative flex items-center w-full h-full"},De={class:"tips"},Pe=J({__name:"content",props:de({condition:{default:null},factor:{},type:{default:"right"}},{input:{},inputModifiers:{},select:{default:()=>null},selectModifiers:{}}),emits:["update:input","update:select"],setup(x){const f=x,k=Z(x,"input"),o=Z(x,"select"),$=P(()=>f.condition===null),S=["in","not_in"],U=P(()=>{const{factor:_}=f;return _.widget.type==="text"}),n=["select","area_select","mult"],O=P(()=>{const{factor:_}=f;return n.includes(_.widget.type)}),w=P(()=>f.type==="left"?!1:f.factor.widget.type==="mult"?!0:S.includes(f.condition||"")),j=P(()=>{const{factor:_}=f,{widget:B}=_;return B.value.map(L=>({label:ne(L)?L:L.label,value:ne(L)?L:L.key}))}),m=()=>{o.value=j.value.map(_=>_.value)},h=()=>{o.value=[]},W=X(""),A=_=>{W.value=_},M=()=>{W.value!==""&&(q(o.value)?q(o.value)&&!o.value.includes(W.value)&&o.value.push(W.value):o.value=[W.value],W.value="")};return(_,B)=>{const L=ce,V=I,z=Y,t=ae;return g(),E("div",je,[d(U)?(g(),E(Q,{key:0},[d(w)?(g(),D(V,{key:1,value:o.value,"onUpdate:value":B[1]||(B[1]=i=>o.value=i),tag:"",multiple:"",filterable:"","show-arrow":!1,show:!1,"max-tag-count":"responsive","consistent-menu-width":!1,placeholder:_.factor.widget.placeholder,onSearch:A,onBlur:M},null,8,["value","placeholder"])):(g(),D(L,{key:0,value:k.value,"onUpdate:value":B[0]||(B[0]=i=>k.value=i),spellcheck:"false",disabled:d($),placeholder:_.factor.widget.placeholder},null,8,["value","disabled","placeholder"])),v("div",De,F(_.factor.widget.hint?"".concat(_.factor.widget.hint).concat(d(w)?_.$t("Waf.Custom.index_29"):""):""),1)],64)):H("",!0),d(O)?(g(),D(V,{key:1,value:o.value,"onUpdate:value":B[2]||(B[2]=i=>o.value=i),options:d(j),disabled:d($),filterable:!0,"consistent-menu-width":!1,multiple:d(w),"max-tag-count":"responsive",placeholder:_.factor.widget.placeholder},we({_:2},[d(w)?{name:"header",fn:y(()=>[p(t,{class:"w-full"},{default:y(()=>[p(z,{class:"flex-1",onClick:m},{default:y(()=>[T(F(_.$t("Public.All")),1)]),_:1}),p(z,{class:"flex-1",onClick:h},{default:y(()=>[T(F(_.$t("Public.Btn.Cancel")),1)]),_:1})]),_:1})]),key:"0"}:void 0]),1032,["value","options","disabled","multiple","placeholder"])):H("",!0)])}}}),se=G(Pe,[["__scopeId","data-v-c8f1f83a"]]),Ae={class:"rows rows-tit"},Ne={class:"field"},Te={class:"condition"},Ve={class:"content"},ze={class:"rows"},He={class:"field"},qe={class:"condition"},Xe={class:"content"},Ze={key:0,class:"w-140px mr-8px"},Ge={class:"flex-1 w-0"},Je={class:"rows-btn"},Ke=["onClick"],Qe=J({__name:"index",props:de({isInit:{type:Boolean,default:!0}},{value:{default:()=>[]},valueModifiers:{}}),emits:["update:value"],setup(x,{expose:f}){const k=x,o=Z(x,"value"),$=te(),S={type:"or",children:[]},U={input:"",select:null,show:!1,widget:{hint:"",placeholder:"",type:"text",value:[]}},n={type:"and",field:null,condition:null,conOptions:[],leftFactor:N(U),rightFactor:N(U)},O=["select","area_select"],w=["in","not_in"],j=P(()=>$.config.options.map(e=>({label:e.text,value:e.type,data:e}))),m=(e,l)=>(c,b)=>{const a=o.value[e].children[l],s=b.data;a.conOptions=s.operators.map(u=>({label:$.getOperatorName(u),value:u})),a.condition=s.operators[0]||null,a.leftFactor=N(U),a.rightFactor=N(U),s.left_factor_enabled&&(a.leftFactor.show=s.left_factor_enabled,a.leftFactor.widget=s.left_widget),s.right_factor_enabled&&(a.rightFactor.widget=s.right_widget,a.rightFactor.show=s.right_factor_enabled)},h=(e,l)=>c=>{const b=o.value[e].children[l],{rightFactor:a}=b,{widget:s}=a;if(O.includes(s.type)){if(a.select===null)return;w.includes(c||"")?a.select=q(a.select)?a.select:[a.select]:a.select=q(a.select)?a.select[0]:a.select}s.type==="text"&&(w.includes(c||"")&&a.input!==""&&(a.select=[a.input],a.input=""),a.select!==null&&(a.input=q(a.select)?a.select[0]:a.select))},W=P(()=>o.value.map(e=>e.children.length).reduce((e,l)=>e+l)>1),A=(e,l)=>!(l!==o.value.length-1||e!==o.value[l].children.length-1),M=(e,l=0)=>{o.value[l].children.splice(e+1,0,N(n))},_=()=>{o.value.push(N(S)),M(0,o.value.length-1)},B=(e,l)=>{const c=o.value[l];c.children.length>1?c.children.splice(e,1):o.value.splice(l,1)},L=(e,l)=>{const{options:c}=$.config;for(let b=0;b<c.length;b++)if(c[b].type===e){l(c[b]);break}},V=(e,l,c)=>c.widget.type==="text"&&!w.includes(l)?e:"",z=(e,l,c)=>e&&e.includes(",")?e?e.split(","):[]:O.includes(c.widget.type)&&e||null,t=e=>{const l=[];e.children.forEach(c=>{const b=N(S);c.children.forEach(a=>{const{option:s}=a;if(!s)return;const u=N(n);u.field=s.type,u.condition=s.operator,L(s.type,r=>{if(r.left_factor_enabled){const C=(s==null?void 0:s.left_factor)||"";u.leftFactor.show=r.left_factor_enabled,u.leftFactor.widget=r.left_widget,u.leftFactor.input=V(C,s.operator,u.leftFactor),u.leftFactor.select=z(C,s.operator,u.leftFactor)}if(r.right_factor_enabled){const C=(s==null?void 0:s.right_factor)||"";u.rightFactor.show=r.right_factor_enabled,u.rightFactor.widget=r.right_widget,u.rightFactor.input=V(C,s.operator,u.rightFactor),u.rightFactor.select=z(C,s.operator,u.rightFactor)}u.conOptions=r.operators.map(C=>({label:$.getOperatorName(C),value:C}))}),b.children.push(u)}),l.push(b)}),l.length>0?o.value=l:_()};return k.isInit&&o.value.length===0&&_(),f({setRules:t}),(e,l)=>{const c=I,b=Y,a=le;return g(),E("div",null,[v("div",Ae,[v("div",Ne,F(e.$t("Waf.Custom.index_26")),1),v("div",Te,F(e.$t("Waf.Custom.index_27")),1),v("div",Ve,F(e.$t("Waf.Custom.index_28")),1),l[0]||(l[0]=v("div",{class:"btn"},null,-1))]),(g(!0),E(Q,null,oe(o.value,(s,u)=>(g(),E("div",{key:"".concat(u+1)},[u!==0?(g(),D(Se,{key:0})):H("",!0),(g(!0),E(Q,null,oe(s.children,(r,C)=>(g(),E("div",{key:"".concat(C+1)},[C!==0?(g(),D(Me,{key:0})):H("",!0),v("div",ze,[v("div",He,[p(c,K({value:r.field,"onUpdate:value":R=>r.field=R,options:d(j),"consistent-menu-width":!1},ee({"update:value":m(u,C)})),null,16,["value","onUpdate:value","options"])]),v("div",qe,[r.leftFactor.show?(g(),D(se,{key:0,input:r.leftFactor.input,"onUpdate:input":R=>r.leftFactor.input=R,select:r.leftFactor.select,"onUpdate:select":R=>r.leftFactor.select=R,type:"left",condition:r.condition,factor:r.leftFactor},null,8,["input","onUpdate:input","select","onUpdate:select","condition","factor"])):(g(),D(c,K({key:1,value:r.condition,"onUpdate:value":R=>r.condition=R,disabled:r.field===null,options:r.conOptions,"consistent-menu-width":!1},ee({"update:value":h(u,C)})),null,16,["value","onUpdate:value","disabled","options"]))]),v("div",Xe,[r.leftFactor.show?(g(),E("div",Ze,[p(c,K({value:r.condition,"onUpdate:value":R=>r.condition=R,disabled:r.field===null,options:r.conOptions,"consistent-menu-width":!1},ee({"update:value":h(u,C)})),null,16,["value","onUpdate:value","disabled","options"])])):H("",!0),v("div",Ge,[p(se,{input:r.rightFactor.input,"onUpdate:input":R=>r.rightFactor.input=R,select:r.rightFactor.select,"onUpdate:select":R=>r.rightFactor.select=R,type:"right",condition:r.condition,factor:r.rightFactor},null,8,["input","onUpdate:input","select","onUpdate:select","condition","factor"])])]),v("div",Je,[p(b,{onClick:R=>M(C,u)},{default:y(()=>[T(F(e.$t("Waf.Custom.index_30")),1)]),_:2},1032,["onClick"]),A(C,u)?(g(),D(b,{key:0,class:"ml-8px",onClick:_},{default:y(()=>[T(F(e.$t("Waf.Custom.index_31")),1)]),_:1})):H("",!0),d(W)?(g(),E("div",{key:1,class:"close",onClick:R=>B(C,u)},[p(a,{name:"base-close",size:"16"})],8,Ke)):H("",!0)])])]))),128))]))),128)),l[1]||(l[1]=v("div",null,null,-1))])}}}),Ye=G(Qe,[["__scopeId","data-v-31e9f077"]]),Ie={class:"p-24px"},et={class:"form-title"},tt={class:"w-320px"},nt={class:"w-320px"},ot={class:"form-title mt-8px"},st={class:"flex-1"},lt={class:"form-title mt-8px"},at=J({__name:"index",props:{isEdit:{type:Boolean},row:{}},emits:["refresh"],setup(x,{expose:f,emit:k}){const o=x,$=k,S=be(o,"isEdit"),{t:U}=ue(),n=ye({name:"",server:[],action:"deny",response:null}),O={name:{trigger:["blur","input"],validator:()=>n.name===""?new Error(U("Waf.Custom.index_18")):!0},rules:{validator:()=>{for(let t=0;t<w.value.length;t++){const i=w.value[t];for(let e=0;e<i.children.length;e++){const l=i.children[e];if(l.field===null||l.condition===null)return new Error(U("Waf.Custom.index_22"));const{leftFactor:c,rightFactor:b}=l;if(c.show&&c.input===""&&c.select===null)return new Error(U("Waf.Custom.index_22"));if(b.show&&b.input===""&&b.select===null)return new Error(U("Waf.Custom.index_22"))}}return!0}}},w=X([]),j=X(null),m=X(),h=()=>{n.server.length>0?fe(n.server.join("\n")):pe.error(U("Waf.Custom.index_24"))},W=()=>{if(!S.value)return;const{row:t}=o;t&&(n.name=t.name,n.server=t.servers||null,n.action=t.action.type,n.response=t.action.response.type,$e(()=>{m.value.setRules(t.root)}))},A=()=>{const t=M();return w.value.forEach(i=>{const e=M("and");i.children.forEach(l=>{(l.field!==null||l.condition!==null)&&e.children.push(_(l))}),t.children.push(e)}),t},M=(t="or")=>({logic:t,type:"block",option:null,children:[]}),_=t=>({type:"option",logic:"",children:[],option:{type:t.field||"",operator:t.condition||"",left_factor:L(t.condition,t.leftFactor),right_factor:L(t.condition,t.rightFactor)}}),B=["in","not_in"],L=(t,i)=>{const{widget:e}=i;return e.type==="text"&&!B.includes(t||"")?i.input:q(i.select)?i.select.join(","):i.select||""},V=()=>{const{action:t,response:i}=n;return t==="allow"&&i===null&&(n.response="black_page"),{name:n.name,servers:n.server?n.server:[],status:1,is_global:0,priority:0,root:A(),action:{type:n.action,response:{type:n.response||"",response_id:0,status:0,headers:{},body:""}}}},z=async()=>{var e;await((e=j.value)==null?void 0:e.validate());const t=V(),{row:i}=o;S.value&&i?await _e({infos:t,id:i.id}):await ve(t),$("refresh")};return W(),f({onConfirm:z}),(t,i)=>{const e=le,l=Y,c=ie,b=ce,a=me;return g(),E("div",Ie,[p(a,{ref_key:"formRef",ref:j,model:d(n),rules:O,"label-width":"140px","label-placement":"left","require-mark-placement":"left"},{default:y(()=>[v("div",et,F(t.$t("Waf.Custom.index_15")),1),p(c,{label:t.$t("Waf.Custom.index_16")},{default:y(()=>[v("div",tt,[p(Ce,{value:d(n).server,"onUpdate:value":i[0]||(i[0]=s=>d(n).server=s)},null,8,["value"])]),p(l,{class:"ml-16px",onClick:h},{default:y(()=>[p(e,{name:"common-copy",class:"mr-6px",size:"14"}),v("span",null,F(t.$t("Waf.Custom.index_23")),1)]),_:1})]),_:1},8,["label"]),p(c,{label:t.$t("Waf.Custom.index_17"),path:"name"},{default:y(()=>[v("div",nt,[p(b,{value:d(n).name,"onUpdate:value":i[1]||(i[1]=s=>d(n).name=s),spellcheck:"false",placeholder:t.$t("Waf.Custom.index_18")},null,8,["value","placeholder"])])]),_:1},8,["label"]),v("div",ot,F(t.$t("Waf.Custom.index_19")),1),p(c,{label:"",class:"pl-36px",path:"rules"},{default:y(()=>[v("div",st,[p(Ye,{ref_key:"ruleListRef",ref:m,value:d(w),"onUpdate:value":i[2]||(i[2]=s=>xe(w)?w.value=s:null),"is-init":!d(S)},null,8,["value","is-init"])])]),_:1}),v("div",lt,F(t.$t("Waf.Custom.index_10")),1),p(Ue,{action:d(n).action,"onUpdate:action":i[3]||(i[3]=s=>d(n).action=s),response:d(n).response,"onUpdate:response":i[4]||(i[4]=s=>d(n).response=s)},null,8,["action","response"])]),_:1},8,["model"])])}}}),ft=G(at,[["__scopeId","data-v-2a17c742"]]);export{ft as default};
|