import{_ as e}from"./index.vue_vue_type_script_setup_true_lang10.js?v=20260328163632";import{u as t,l as r,t as a,x as s}from"./utils-lib.js?v=20260328163632";import{u as i}from"./store4.js?v=20260328163632";import{aX as l}from"./site.js?v=20260328163632";import{B as u}from"./index97.js?v=20260328163632";import{v as p}from"./useMethod5.js?v=20260328163632";import{k as m,r as o,c as n,O as v,o as c,U as b,Y as d,V as y,W as _,X as f,l as x,_ as g,a3 as h,Z as k,a1 as j,F as w,j as E,u as N}from"./base-lib.js?v=20260328163632";import{N as I}from"./naive-ui.js?v=20260328163632";const O={class:"relative"},T={key:1,class:"bg-[var(--bg-color-79)] flex items-center justify-center h-full",style:{"min-height":"600px"}},B={class:"bg-white px-[48px] py-[16px] text-[var(--text-color-1)] flex"};const K=m({__name:"index",props:{compData:{default:()=>{}}},setup(m,{expose:K}){const A=m,{siteInfo:C,siteType:D,isBindExtranet:S,jumpTabEvent:U}=i(),{plugin:W,isIIS:X}=t(),q=o(!1),F=n((()=>A.compData&&Array.isArray(A.compData)||!1)),M=[{label:r("论坛/博客"),value:0,items:{perserver:300,perip:25,limit_rate:512}},{label:r("图片站"),value:1,items:{perserver:200,perip:10,limit_rate:1024}},{label:r("下载站"),value:2,items:{perserver:50,perip:3,limit_rate:2048}},{label:r("商城"),value:3,items:{perserver:500,perip:10,limit_rate:2048}},{label:r("门户"),value:4,items:{perserver:400,perip:15,limit_rate:1024}},{label:r("企业"),value:5,items:{perserver:60,perip:10,limit_rate:512}},{label:r("视频"),value:6,items:{perserver:150,perip:4,limit_rate:1024}},{label:r("自定义"),value:7,items:{perserver:"",perip:"",limit_rate:""}}],V={labelStyle:"min-width: 120px"},Y=o({label:r("是否启用"),attrs:V,children:[{type:"custom",key:"status",render:()=>{let e;return v(I,{checked:ee.value.status,"onUpdate:checked":e=>ee.value.status=e},"function"==typeof(t=e=r("启用流量限制"))||"[object Object]"===Object.prototype.toString.call(t)&&!N(t)?e:{default:()=>[e]});var t}}]}),Z=e=>{const{perserver:t,limit_rate:r}=M[e].items;ee.value.limit=e,ee.value.perserver=t,ee.value.limit_rate=r},z=o({label:r("限制方案"),attrs:V,children:[{type:"select",key:"limit",attrs:{options:M,"onUpdate:value":Z}}]}),G=o({label:r("并发限制"),attrs:V,ruleKey:"perserver",rules:[{validator:(e,t)=>""===t?new Error(r("请输入并发限制")):t>65535?new Error(r("不能大于65535")):!!Number.isInteger(1*t)||new Error(r("输入必须为整数")),trigger:["blur","input"]}],children:[{type:"input",key:"perserver",attrs:{placeholder:r("请输入并发限制"),class:"!w-200px"}},{type:"custom",key:"perserverTips",render:()=>v("div",{class:"flex items-center ml-10px text-light"},[r("* 限制当前站点最大并发数")])}]}),H=o({label:r("超时时间"),attrs:V,ruleKey:"timeout",rules:[{validator:(e,t)=>""===t?new Error(r("请输入超时时间")):!(!Number.isInteger(1*t)||t<0)||new Error(r("输入必须为整数")),trigger:["blur","input"]}],children:[{type:"input",key:"timeout",attrs:{placeholder:r("请输入超时时间"),class:"!w-200px"}}]}),J=o({label:r("流量限制"),attrs:V,ruleKey:"limit_rate",rules:[{validator:(e,t)=>""===t?new Error(r("请输入流量限制")):!!Number.isInteger(1*t)||new Error(r("输入必须为整数")),trigger:["blur","input"]}],children:[{type:"input",key:"limit_rate"},{type:"custom",key:"perserverTips",render:()=>v("div",{class:"flex items-center ml-10px text-light"},[r("* 限制每个请求的流量上限（单位：KB）")])}]}),L=async e=>{await te.value.validate();const{limit:t,perip:r,limit_rate:a,perserver:i,timeout:u,status:p}=ee.value;let m={siteid:C.value.id,status:p,limit_rate:Number(a),perserver:Number(i),timeout:Number(u)};s({loading:q,request:l(m),message:!0,success:re})},P=o({label:" ",children:[{type:"button",key:"save",attrs:{type:"primary",buttonText:r("保存"),onClick:L}}]}),Q=o({formAttrs:{labelWidth:"auto"},formItems:[]}),R=n((()=>(Q.value.formItems=[Y.value,z.value,G.value,H.value,J.value,...F.value?[]:[P.value]],Q.value))),[$,ee,te]=a(R),re=async()=>{if(Number(C.value.status)||!X.value||"php"!==D.value)if(F.value)Object.assign(ee.value,{limit:0,timeout:120,status:!0}),Z(0);else{const{limit:e}=await p();if(e)if(Object.assign(ee.value,{...e,limit:0,timeout:e.timeout||120}),ee.value.status=Boolean(e.status),0===e.limit_rate&&0===e.perserver)Z(0);else{const t=M.find((t=>t.items.perserver===e.perserver&&t.items.limit_rate===e.limit_rate));ee.value.limit=t?t.value:7,ee.value.status||Z(0)}}};return c(re),K({onConfirm:L,init:re}),(t,a)=>{const s=b("bt-loading");return d(S)?(y(),_(w,{key:0},[f("div",O,[x(v(d($),null,null,512),[[s,d(q)]]),"apache"===d(W).webserver?(y(),g(u,{key:0},{content:h((()=>[f("p",null,k(d(r)("流量限制不支持apache")),1)])),_:1})):j("",!0)]),!Number(d(C).status)&&d(X)&&"php"===d(D)?(y(),g(e,{key:0})):j("",!0)],64)):(y(),_("div",T,[f("div",B,[E(k(d(r)("请开启"))+" ",1),f("span",{class:"mx-[.4rem] bt-link",onClick:a[0]||(a[0]=e=>d(U)("mapping"))},k(d(r)("外网映射")),1),E(" "+k(d(r)("后查看配置信息")),1)])]))}}});export{K as _};
