2 lines
15 KiB
JavaScript
2 lines
15 KiB
JavaScript
System.register(["./index-legacy-DQdImDha.js?v=1773287522785","./copy-legacy-CoXPjkKf.js?v=1773287522785","./custom-legacy-BOQU43Jz.js?v=1773287522785","./naive-ui-legacy-BW82sq8q.js?v=1773287522785","./vue-core-legacy-Cn1vuJ3s.js?v=1773287522785","./prismjs-legacy-BN0FEcG9.js?v=1773287522785"],(function(e,t){"use strict";var l,a,n,o,i,s,r,c,u,d,p,f,v,h,m,g,_,x,w,y,b,C,k,F,$,U,W,j,E,O,B,I,M,P,R,z,S,A,N,q,H,L,X,Z;return{setters:[e=>{l=e.c,a=e.ao,n=e.n,o=e.l,i=e.m},e=>{s=e.c},e=>{r=e.u,c=e.e,u=e.a},e=>{d=e.aH,p=e.B,f=e.a6,v=e.a1,h=e.o,m=e.b,g=e.p,_=e.a7},e=>{x=e.k,w=e.an,y=e.r,b=e.$,C=e.a8,k=e.a9,F=e.a0,$=e.j,U=e.aa,W=e.s,j=e.S,E=e.R,O=e.c,B=e.Z,I=e.F,M=e._,P=e.l,R=e.v,z=e.ak,S=e.au,A=e.ao,N=e.P,q=e.ay,H=e.t,L=e.e,X=e.X,Z=e.n},null],execute:function(){var t=document.createElement("style");t.textContent=".seg[data-v-7ea28fa1]{width:1px;height:8px;margin:0 auto;border-left:1px solid #ccc}.tips[data-v-c8f1f83a]{position:absolute;top:32px;left:0;width:100%;padding-top:2px;padding-left:2px;color:#999}.rows[data-v-31e9f077]{display:flex}.rows .field[data-v-31e9f077]{width:140px;margin-right:8px}.rows .condition[data-v-31e9f077]{width:160px;margin-right:8px}.rows .content[data-v-31e9f077]{display:flex;flex:1;width:0;flex-shrink:0}.rows .rows-btn[data-v-31e9f077]{display:flex;align-items:center;margin-left:8px}.rows .rows-btn .close[data-v-31e9f077]{display:flex;align-items:center;justify-content:center;width:24px;height:32px;margin-left:8px;color:#666;cursor:pointer;transition:opacity .3s}.rows .rows-btn .close[data-v-31e9f077]:hover{opacity:.8}.rows.rows-tit>div[data-v-31e9f077]{padding-bottom:8px}.form-title[data-v-2a17c742]{margin-bottom:20px;font-size:16px}\n/*$vite$:1*/",document.head.appendChild(t);const D=x({__name:"site-select",props:{value:{},valueModifiers:{}},emits:["update:value"],setup(e){const t=w(e,"value"),l=r(),a=y([]),n=()=>{t.value=a.value.map((e=>e.value))},o=()=>{t.value=[]};return(async()=>{a.value=Object.entries(l.config.sitemap).map((([e,t])=>({label:e,value:t})))})(),(e,l)=>{const i=p,s=d,r=f;return b(),C(r,W(e.$attrs,{value:t.value,"onUpdate:value":l[0]||(l[0]=e=>t.value=e),multiple:"",filterable:"",options:j(a),"max-tag-count":"responsive","consistent-menu-width":!1,placeholder:e.$t("Waf.Custom.index_25")}),{header:k((()=>[F(s,{class:"w-full"},{default:k((()=>[F(i,{class:"flex-1",onClick:n},{default:k((()=>[$(U(e.$t("Public.All")),1)])),_:1}),F(i,{class:"flex-1",onClick:o},{default:k((()=>[$(U(e.$t("Public.Btn.Cancel")),1)])),_:1})])),_:1})])),_:1},16,["value","options","placeholder"])}}}),G={class:"w-320px"},J={class:"w-320px"},K=x({__name:"action",props:{action:{default:""},actionModifiers:{},response:{},responseModifiers:{}},emits:["update:action","update:response"],setup(e){const{t:t}=E(),l=r(),a=w(e,"action"),n=w(e,"response"),o=y([]),i=O((()=>{let e="";switch(a.value){case"deny":e=t("Waf.Custom.index_21");break;case"validate":e=t("Waf.Custom.index_32")}return e})),s=O((()=>c(a.value).map((e=>({label:e.text,value:e.type,data:e}))))),c=e=>{const t=l.config.action.filter((t=>t.type===e));return t.length>0?t[0].response:[]},u=e=>{const t=c(e);t.length>0?n.value=t[0].type:n.value=null};return o.value=l.config.action.map((e=>({label:e.text,value:e.type,data:e}))),null===n.value&&u(a.value),(e,t)=>{const l=f,r=v;return b(),B(I,null,[F(r,{label:e.$t("Waf.Custom.index_20")},{default:k((()=>[M("div",G,[F(l,{value:a.value,"onUpdate:value":[t[0]||(t[0]=e=>a.value=e),u],options:j(o)},null,8,["value","options"])])])),_:1},8,["label"]),P(F(r,{label:j(i),"show-feedback":!1},{default:k((()=>[M("div",J,[F(l,{value:n.value,"onUpdate:value":t[1]||(t[1]=e=>n.value=e),options:j(s)},null,8,["value","options"])])])),_:1},8,["label"]),[[R,j(s).length>0]])],64)}}}),Q={class:"my-18px"},T=l({},[["render",function(e,t){const l=h;return b(),B("div",Q,[F(l,{class:"w-38px justify-center"},{default:k((()=>[$(U(e.$t("Waf.Custom.index_31")),1)])),_:1})])}]]),V={class:"flex flex-center flex-col w-38px"},Y=l({},[["render",function(e,t){const l=h;return b(),B("div",V,[t[0]||(t[0]=M("div",{class:"seg"},null,-1)),F(l,{class:"w-38px justify-center"},{default:k((()=>[$(U(e.$t("Waf.Custom.index_30")),1)])),_:1}),t[1]||(t[1]=M("div",{class:"seg"},null,-1))])}],["__scopeId","data-v-7ea28fa1"]]),ee={class:"relative flex items-center w-full h-full"},te={class:"tips"},le=l(x({__name:"content",props:A({condition:{default:null},factor:{},type:{default:"right"}},{input:{},inputModifiers:{},select:{default:()=>null},selectModifiers:{}}),emits:["update:input","update:select"],setup(e){const t=e,l=w(e,"input"),o=w(e,"select"),i=O((()=>null===t.condition)),s=["in","not_in"],r=O((()=>{const{factor:e}=t;return"text"===e.widget.type})),c=["select","area_select","mult"],u=O((()=>{const{factor:e}=t;return c.includes(e.widget.type)})),v=O((()=>"left"!==t.type&&("mult"===t.factor.widget.type||s.includes(t.condition||"")))),h=O((()=>{const{factor:e}=t,{widget:l}=e;return l.value.map((e=>({label:a(e)?e:e.label,value:a(e)?e:e.key})))})),g=()=>{o.value=h.value.map((e=>e.value))},_=()=>{o.value=[]},x=y(""),W=e=>{x.value=e},E=()=>{""!==x.value&&(n(o.value)?n(o.value)&&!o.value.includes(x.value)&&o.value.push(x.value):o.value=[x.value],x.value="")};return(e,t)=>{const a=m,n=f,s=p,c=d;return b(),B("div",ee,[j(r)?(b(),B(I,{key:0},[j(v)?(b(),C(n,{key:1,value:o.value,"onUpdate:value":t[1]||(t[1]=e=>o.value=e),tag:"",multiple:"",filterable:"","show-arrow":!1,show:!1,"max-tag-count":"responsive","consistent-menu-width":!1,placeholder:e.factor.widget.placeholder,onSearch:W,onBlur:E},null,8,["value","placeholder"])):(b(),C(a,{key:0,value:l.value,"onUpdate:value":t[0]||(t[0]=e=>l.value=e),spellcheck:"false",disabled:j(i),placeholder:e.factor.widget.placeholder},null,8,["value","disabled","placeholder"])),M("div",te,U(e.factor.widget.hint?`${e.factor.widget.hint}${j(v)?e.$t("Waf.Custom.index_29"):""}`:""),1)],64)):z("",!0),j(u)?(b(),C(n,{key:1,value:o.value,"onUpdate:value":t[2]||(t[2]=e=>o.value=e),options:j(h),disabled:j(i),filterable:!0,"consistent-menu-width":!1,multiple:j(v),"max-tag-count":"responsive",placeholder:e.factor.widget.placeholder},S({_:2},[j(v)?{name:"header",fn:k((()=>[F(c,{class:"w-full"},{default:k((()=>[F(s,{class:"flex-1",onClick:g},{default:k((()=>[$(U(e.$t("Public.All")),1)])),_:1}),F(s,{class:"flex-1",onClick:_},{default:k((()=>[$(U(e.$t("Public.Btn.Cancel")),1)])),_:1})])),_:1})])),key:"0"}:void 0]),1032,["value","options","disabled","multiple","placeholder"])):z("",!0)])}}}),[["__scopeId","data-v-c8f1f83a"]]),ae={class:"rows rows-tit"},ne={class:"field"},oe={class:"condition"},ie={class:"content"},se={class:"rows"},re={class:"field"},ce={class:"condition"},ue={class:"content"},de={key:0,class:"w-140px mr-8px"},pe={class:"flex-1 w-0"},fe={class:"rows-btn"},ve=["onClick"],he=x({__name:"index",props:A({isInit:{type:Boolean,default:!0}},{value:{default:()=>[]},valueModifiers:{}}),emits:["update:value"],setup(e,{expose:t}){const l=e,a=w(e,"value"),i=r(),s={type:"or",children:[]},c={input:"",select:null,show:!1,widget:{hint:"",placeholder:"",type:"text",value:[]}},u={type:"and",field:null,condition:null,conOptions:[],leftFactor:g(c),rightFactor:g(c)},d=["select","area_select"],v=["in","not_in"],h=O((()=>i.config.options.map((e=>({label:e.text,value:e.type,data:e}))))),m=(e,t)=>(l,n)=>{const o=a.value[e].children[t],s=n.data;o.conOptions=s.operators.map((e=>({label:i.getOperatorName(e),value:e}))),o.condition=s.operators[0]||null,o.leftFactor=g(c),o.rightFactor=g(c),s.left_factor_enabled&&(o.leftFactor.show=s.left_factor_enabled,o.leftFactor.widget=s.left_widget),s.right_factor_enabled&&(o.rightFactor.widget=s.right_widget,o.rightFactor.show=s.right_factor_enabled)},_=(e,t)=>l=>{const o=a.value[e].children[t],{rightFactor:i}=o,{widget:s}=i;if(d.includes(s.type)){if(null===i.select)return;v.includes(l||"")?i.select=n(i.select)?i.select:[i.select]:i.select=n(i.select)?i.select[0]:i.select}"text"===s.type&&(v.includes(l||"")&&""!==i.input&&(i.select=[i.input],i.input=""),null!==i.select&&(i.input=n(i.select)?i.select[0]:i.select))},x=O((()=>a.value.map((e=>e.children.length)).reduce(((e,t)=>e+t))>1)),y=(e,t)=>t===a.value.length-1&&e===a.value[t].children.length-1,E=(e,t=0)=>{a.value[t].children.splice(e+1,0,g(u))},P=()=>{a.value.push(g(s)),E(0,a.value.length-1)},R=(e,t,l)=>"text"!==l.widget.type||v.includes(t)?"":e,S=(e,t,l)=>e&&e.includes(",")?e?e.split(","):[]:d.includes(l.widget.type)&&e||null;return l.isInit&&0===a.value.length&&P(),t({setRules:e=>{const t=[];e.children.forEach((e=>{const l=g(s);e.children.forEach((e=>{const{option:t}=e;if(!t)return;const a=g(u);a.field=t.type,a.condition=t.operator,((e,t)=>{const{options:l}=i.config;for(let a=0;a<l.length;a++)if(l[a].type===e){t(l[a]);break}})(t.type,(e=>{if(e.left_factor_enabled){const l=t?.left_factor||"";a.leftFactor.show=e.left_factor_enabled,a.leftFactor.widget=e.left_widget,a.leftFactor.input=R(l,t.operator,a.leftFactor),a.leftFactor.select=S(l,t.operator,a.leftFactor)}if(e.right_factor_enabled){const l=t?.right_factor||"";a.rightFactor.show=e.right_factor_enabled,a.rightFactor.widget=e.right_widget,a.rightFactor.input=R(l,t.operator,a.rightFactor),a.rightFactor.select=S(l,t.operator,a.rightFactor)}a.conOptions=e.operators.map((e=>({label:i.getOperatorName(e),value:e})))})),l.children.push(a)})),t.push(l)})),t.length>0?a.value=t:P()}}),(e,t)=>{const l=f,n=p,i=o;return b(),B("div",null,[M("div",ae,[M("div",ne,U(e.$t("Waf.Custom.index_26")),1),M("div",oe,U(e.$t("Waf.Custom.index_27")),1),M("div",ie,U(e.$t("Waf.Custom.index_28")),1),t[0]||(t[0]=M("div",{class:"btn"},null,-1))]),(b(!0),B(I,null,N(a.value,((t,o)=>(b(),B("div",{key:`${o+1}`},[0!==o?(b(),C(T,{key:0})):z("",!0),(b(!0),B(I,null,N(t.children,((t,s)=>(b(),B("div",{key:`${s+1}`},[0!==s?(b(),C(Y,{key:0})):z("",!0),M("div",se,[M("div",re,[F(l,W({value:t.field,"onUpdate:value":e=>t.field=e,options:j(h),"consistent-menu-width":!1},q({"update:value":m(o,s)})),null,16,["value","onUpdate:value","options"])]),M("div",ce,[t.leftFactor.show?(b(),C(le,{key:0,input:t.leftFactor.input,"onUpdate:input":e=>t.leftFactor.input=e,select:t.leftFactor.select,"onUpdate:select":e=>t.leftFactor.select=e,type:"left",condition:t.condition,factor:t.leftFactor},null,8,["input","onUpdate:input","select","onUpdate:select","condition","factor"])):(b(),C(l,W({key:1,value:t.condition,"onUpdate:value":e=>t.condition=e,disabled:null===t.field,options:t.conOptions,"consistent-menu-width":!1},q({"update:value":_(o,s)})),null,16,["value","onUpdate:value","disabled","options"]))]),M("div",ue,[t.leftFactor.show?(b(),B("div",de,[F(l,W({value:t.condition,"onUpdate:value":e=>t.condition=e,disabled:null===t.field,options:t.conOptions,"consistent-menu-width":!1},q({"update:value":_(o,s)})),null,16,["value","onUpdate:value","disabled","options"])])):z("",!0),M("div",pe,[F(le,{input:t.rightFactor.input,"onUpdate:input":e=>t.rightFactor.input=e,select:t.rightFactor.select,"onUpdate:select":e=>t.rightFactor.select=e,type:"right",condition:t.condition,factor:t.rightFactor},null,8,["input","onUpdate:input","select","onUpdate:select","condition","factor"])])]),M("div",fe,[F(n,{onClick:e=>E(s,o)},{default:k((()=>[$(U(e.$t("Waf.Custom.index_30")),1)])),_:2},1032,["onClick"]),y(s,o)?(b(),C(n,{key:0,class:"ml-8px",onClick:P},{default:k((()=>[$(U(e.$t("Waf.Custom.index_31")),1)])),_:1})):z("",!0),j(x)?(b(),B("div",{key:1,class:"close",onClick:e=>((e,t)=>{const l=a.value[t];l.children.length>1?l.children.splice(e,1):a.value.splice(t,1)})(s,o)},[F(i,{name:"base-close",size:"16"})],8,ve)):z("",!0)])])])))),128))])))),128)),t[1]||(t[1]=M("div",null,null,-1))])}}}),me=l(he,[["__scopeId","data-v-31e9f077"]]),ge={class:"p-24px"},_e={class:"form-title"},xe={class:"w-320px"},we={class:"w-320px"},ye={class:"form-title mt-8px"},be={class:"flex-1"},Ce={class:"form-title mt-8px"},ke=x({__name:"index",props:{isEdit:{type:Boolean},row:{}},emits:["refresh"],setup(e,{expose:t,emit:l}){const a=e,r=l,d=H(a,"isEdit"),{t:f}=E(),h=L({name:"",server:[],action:"deny",response:null}),g={name:{trigger:["blur","input"],validator:()=>""!==h.name||new Error(f("Waf.Custom.index_18"))},rules:{validator:()=>{for(let e=0;e<x.value.length;e++){const t=x.value[e];for(let e=0;e<t.children.length;e++){const l=t.children[e];if(null===l.field||null===l.condition)return new Error(f("Waf.Custom.index_22"));const{leftFactor:a,rightFactor:n}=l;if(a.show&&""===a.input&&null===a.select)return new Error(f("Waf.Custom.index_22"));if(n.show&&""===n.input&&null===n.select)return new Error(f("Waf.Custom.index_22"))}}return!0}}},x=y([]),w=y(null),C=y(),$=()=>{h.server.length>0?s(h.server.join("\n")):i.error(f("Waf.Custom.index_24"))},W=()=>{const e=O();return x.value.forEach((t=>{const l=O("and");t.children.forEach((e=>{null===e.field&&null===e.condition||l.children.push(I(e))})),e.children.push(l)})),e},O=(e="or")=>({logic:e,type:"block",option:null,children:[]}),I=e=>({type:"option",logic:"",children:[],option:{type:e.field||"",operator:e.condition||"",left_factor:R(e.condition,e.leftFactor),right_factor:R(e.condition,e.rightFactor)}}),P=["in","not_in"],R=(e,t)=>{const{widget:l}=t;return"text"!==l.type||P.includes(e||"")?n(t.select)?t.select.join(","):t.select||"":t.input};return(()=>{if(!d.value)return;const{row:e}=a;e&&(h.name=e.name,h.server=e.servers||null,h.action=e.action.type,h.response=e.action.response.type,Z((()=>{C.value.setRules(e.root)})))})(),t({onConfirm:async()=>{await(w.value?.validate());const e=(()=>{const{action:e,response:t}=h;return"allow"===e&&null===t&&(h.response="black_page"),{name:h.name,servers:h.server?h.server:[],status:1,is_global:0,priority:0,root:W(),action:{type:h.action,response:{type:h.response||"",response_id:0,status:0,headers:{},body:""}}}})(),{row:t}=a;d.value&&t?await c({infos:e,id:t.id}):await u(e),r("refresh")}}),(e,t)=>{const l=o,a=p,n=v,i=m,s=_;return b(),B("div",ge,[F(s,{ref_key:"formRef",ref:w,model:j(h),rules:g,"label-width":"140px","label-placement":"left","require-mark-placement":"left"},{default:k((()=>[M("div",_e,U(e.$t("Waf.Custom.index_15")),1),F(n,{label:e.$t("Waf.Custom.index_16")},{default:k((()=>[M("div",xe,[F(D,{value:j(h).server,"onUpdate:value":t[0]||(t[0]=e=>j(h).server=e)},null,8,["value"])]),F(a,{class:"ml-16px",onClick:$},{default:k((()=>[F(l,{name:"common-copy",class:"mr-6px",size:"14"}),M("span",null,U(e.$t("Waf.Custom.index_23")),1)])),_:1})])),_:1},8,["label"]),F(n,{label:e.$t("Waf.Custom.index_17"),path:"name"},{default:k((()=>[M("div",we,[F(i,{value:j(h).name,"onUpdate:value":t[1]||(t[1]=e=>j(h).name=e),spellcheck:"false",placeholder:e.$t("Waf.Custom.index_18")},null,8,["value","placeholder"])])])),_:1},8,["label"]),M("div",ye,U(e.$t("Waf.Custom.index_19")),1),F(n,{label:"",class:"pl-36px",path:"rules"},{default:k((()=>[M("div",be,[F(me,{ref_key:"ruleListRef",ref:C,value:j(x),"onUpdate:value":t[2]||(t[2]=e=>X(x)?x.value=e:null),"is-init":!j(d)},null,8,["value","is-init"])])])),_:1}),M("div",Ce,U(e.$t("Waf.Custom.index_10")),1),F(K,{action:j(h).action,"onUpdate:action":t[3]||(t[3]=e=>j(h).action=e),response:j(h).response,"onUpdate:response":t[4]||(t[4]=e=>j(h).response=e)},null,8,["action","response"])])),_:1},8,["model"])])}}});e("default",l(ke,[["__scopeId","data-v-2a17c742"]]))}}}));
|