File: /www/server/panel/BTPanel/static/js/page8.js
import{t as u,J as p,f as m,w as b,b as g,P as h,a3 as y}from"./utils-lib.js?v=1777008528";import{_ as P}from"./index109.js?v=1777008528";import{e as l,ap as O,c as T,x as v,y as I,C as r,z as s,D as L}from"./base-lib.js?v=1777008528";import{u as S}from"./hooks2.js?v=1777008528";import{f as _}from"./site-list.js?v=1777008528";import{$ as C,a0 as x,a1 as A,a2 as N,a3 as E}from"./index432.js?v=1777008528";import{u as R}from"./column.js?v=1777008528";async function U(){var a,e;const t=await C(),n=(e=(a=t.data)!=null?a:t)!=null?e:{};if(Array.isArray(n))return n;if(n&&typeof n=="object"&&"msg"in n){const o=n.msg;if(Array.isArray(o))return o}return[]}async function w(t){await N({id:t})}async function k(t){await E({id:t})}async function et(t){return x({data:JSON.stringify(t)})}async function nt(t){return A({data:JSON.stringify(t)})}function D(t){if(typeof t=="string")return t==="allsite"?"所有站点":t;const n=Object.keys(t);return n.length===0||n.length===1&&n[0]==="allsite"?"所有站点":n.join(", ")}function $(t){var o;const n=t.condition===1?"单个IP ":t.condition===2?"单个IP+UA ":"所有IP ",{region:a}=t;let e=n;if(a.req&&(e+="每秒访问设定的URL超过".concat(a.req,"次")),(o=a.count)!=null&&o.count){const i=a.req?" 或在 ":"";e+="".concat(i).concat(a.count.time,"秒内访问该URL超过").concat(a.count.count,"次")}return"".concat(e,"时,将触发流量限制")}function j(t){return{status_403:"状态码403(拒绝访问)",status_404:"状态码404(文件不存在)",status_502:"状态码502(连接超时)",status_503:"状态码503(服务器不可用)",content:"返回网页内容",drop:"拦截(封锁IP)"}[t]||t}const M=(t,n,a)=>[{prop:"name",label:"规则名称",minWidth:120},{prop:"site",label:"网站名",minWidth:160,render:e=>l("span",null,[D(e.site)])},{prop:"url",label:"URL",minWidth:160},{prop:"region",label:"触发条件",minWidth:280,render:e=>l("span",null,[$(e)])},{prop:"action",label:"执行操作",width:200,render:e=>l("span",null,[j(e.action)])},{prop:"open",label:"状态",width:80,render:e=>l(O,{modelValue:e.open,onChange:()=>t(e)},null)},R([{title:"编辑",onClick:e=>n(e)},{title:"删除",onClick:e=>a(e)}])],{BtTable:V,refresh:c}=S({request:async()=>{await _();const t=await U();return{data:t,total:t.length}},columns:M(W,B,H)});async function W(t){const n=t.open;t.open=!t.open;try{await w(t.id),m().success(t.open?"已启用":"已禁用")}catch(a){t.open=n}}async function q(){u({title:"添加流量限制",area:"580px",component:()=>p(()=>import("./index450.js?v=1777008528"),__vite__mapDeps([]),import.meta.url),compData:{mode:"create"},btn:["添加","取消"],onConfirm:async()=>(c(),!0)})}async function B(t){await _(),u({title:"修改流量限制 - ".concat(t.name),area:"580px",component:()=>p(()=>import("./index450.js?v=1777008528"),__vite__mapDeps([]),import.meta.url),compData:{mode:"edit",row:t},btn:["保存","取消"],onConfirm:async()=>(c(),!0)})}async function H(t){try{await b({content:"确认删除规则「".concat(t.name,"」?删除后不可恢复。")}),await k(t.id),m().success("规则已删除"),c()}catch(n){}}const at=[{label:"指定URL",value:"url"},{label:"全站",value:"all"}],ot=[{label:"单个IP",value:1},{label:"IP+UA",value:2},{label:"所有IP",value:3}],lt=[{label:"状态码403(拒绝访问)",value:"status_403"},{label:"状态码404(文件不存在)",value:"status_404"},{label:"状态码502(连接超时)",value:"status_502"},{label:"状态码503(服务器不可用)",value:"status_503"},{label:"返回网页内容",value:"content"},{label:"封锁IP",value:"drop"}],st=[{label:"默认流量限制页(HTML格式)",value:"html"},{label:"默认流量限制页(Json格式)",value:"json"},{label:"444响应",value:"444"}],J=["流量限制的优先级是最低的","流量限制一般用于API接口 不建议使用全站开启","建议的返回类型为503或者502","如果你想修改返回的内容、文件在/www/server/btwaf/html目录中分别是limit.html和limit.json,修改后需重启Nginx生效"],z={class:"flex flex-col gap-4"},G=T({__name:"page",setup(t){const{mainHeight:n}=g(),a=J.map(e=>({content:e}));return(e,o)=>{const i=h,f=P,d=y;return v(),I("div",z,[l(f,null,{"header-left":r(()=>[l(i,{type:"primary",onClick:s(q)},{default:r(()=>[...o[0]||(o[0]=[L("添加限制",-1)])]),_:1},8,["onClick"])]),content:r(()=>[l(s(V),{"max-height":s(n)-274},null,8,["max-height"])]),_:1}),l(d,{"list-style":"disc",options:s(a)},null,8,["options"])])}}}),it=Object.freeze(Object.defineProperty({__proto__:null,default:G},Symbol.toStringTag,{value:"Module"}));export{lt as A,ot as C,at as P,st as R,et as c,it as p,nt as u};
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
__vite__mapDeps.viteFileDeps = []
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}