import{x as e,aw as a,is as t,e as s,l}from"./utils-lib.js?v=1761009159";import{c as r,r as i,o as n,aD as o,q as u,v as p,x as d,z as m,e as c,B as y,F as g,b0 as b,y as f,N as h,Q as v,C as _,D as x,bp as j,ak as k,al as w,aj as C,ah as P}from"./base-lib.js?v=1761009159";import{createIpRules as D,removeIpRules as O,getIpFlowsAreasInfo as V,getIpFlowTrend as I}from"./site.js?v=1761009159";import{f as q}from"./useController5.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./column.js?v=1761009159";import"./index106.js?v=1761009159";import"./useStore4.js?v=1761009159";import"./useController6.js?v=1761009159";import"./validator.js?v=1761009159";import"./useMethod5.js?v=1761009159";const N={class:"p-[2rem]"},S={class:"flex items-center justify-between mb-[8px]"},E={key:1},Q=r({__name:"index",props:{compData:{default:()=>({})}},setup(r){var Q,A;const B=r,{proxy:H}=j(),J=i("PHPMOD"===(null==(A=null==(Q=B.compData)?void 0:Q.project_config)?void 0:A.type)),M=i(),T=i("today"),U=n([{label:"IP地址",prop:"ip",render:e=>o("span",{class:e.deny_status?"line-through text-disabled cursor-pointer":"text-primary cursor-pointer",on:{click:async()=>{try{await H.$confirm({title:"IP地址",message:"确定要".concat(e.deny_status?"解封":"封禁","当前ip吗？"),icon:"warning"});let a=null;if(e.deny_status)a=await O({data:JSON.stringify({address:e.ip})});else{let t={choose:"address",address:e.ip,domain:"",types:"drop",brief:"网站流量点击IP手动封禁"};a=await D({data:JSON.stringify(t)})}H.$message.request(a),X()}catch(a){}}}},e.ip)},{label:"归属地",render:e=>o("div",{class:"flex",style:{gap:"4px"}},[o("span",e.country),o("span",e.province),o("span",e.city)])},{label:"造成流量",prop:"flow",render:a=>o("span",e(a.flow))}]),$=i([{title:"今天",key:"today"},{title:"昨天",key:"yesterday"},{title:"近7天",key:"l7"},{title:"近30天",key:"l30"},{title:"近1小时",key:"h1"}]),z=i([]),F=i("流量趋势"),{BtECharts:L,getEChart:G,setOption:K,setQuickOption:R}=a({options:{xAxis:{type:"category",data:[]},yAxis:{type:"value",name:"单位:字节",axisLabel:{margin:2,formatter:function(e,a){return e>=1e4&&e<1e7?e=e/1e4+"万":e>=1e7&&(e=e/1e7+"千万"),e}}},grid:{show:!1,bottom:"20%",right:"5%"},series:[{data:[],type:"line"}]}}),W=async()=>{let e=[],a=[0,0,0,0,0,0,0],t=!1;try{const s=await I({site_name:B.compData.name,query_date:T.value});s&&(a=[]),s.forEach(s=>{"h1"!=T.value&&"today"!=T.value&&"yesterday"!=T.value||(t=!0),e.push(ae(String(s.time),t)),a.push(s.flow)})}catch(s){}R(e,a)},X=async()=>{try{const e=await V({site_name:B.compData.name,query_date:T.value});z.value=e}catch(e){}},Y=e=>{F.value=e,"流量趋势"===e?W():X()},Z=e=>{T.value=e,"流量趋势"===F.value?W():X()},ee=()=>{q({...B.compData,tabName:"flowQuota"},"limit")},ae=(e,a)=>{let t="";return a?(t=e.substring(8,10)+":"+(12===e.length?e.substring(10,12):"00"),t):(12===e.length||10===e.length?t=e.substring(0,4)+"-"+e.substring(4,6)+"-"+e.substring(6,8)+" "+e.substring(8,10)+":"+(12===e.length?e.substring(10,12):"00"):8===e.length&&(t=e.substring(0,4)+"-"+e.substring(4,6)+"-"+e.substring(6,8)),t)};return u(()=>{W()}),(e,a)=>{const r=k,i=w,n=C,o=P,u=s,j=l;return p(),d("div",N,[m("div",S,[c(i,{modelValue:f(T),"onUpdate:modelValue":a[0]||(a[0]=e=>v(T)?T.value=e:null),onChange:Z,class:"!w-[10rem]"},{default:y(()=>[(p(!0),d(g,null,b(f($),(e,a)=>(p(),h(r,{key:a,label:e.title,value:e.key},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),c(o,{modelValue:f(F),"onUpdate:modelValue":a[1]||(a[1]=e=>v(F)?F.value=e:null),onChange:Y},{default:y(()=>[c(n,{label:"流量趋势"}),c(n,{label:"IP TOP 10"})]),_:1},8,["modelValue"]),f(t)||f(J)?x("",!0):(p(),h(u,{key:0,onClick:ee},{default:y(()=>a[2]||(a[2]=[_("流量限额>>",-1)])),_:1,__:[2]}))]),m("div",null,["流量趋势"===f(F)?(p(),h(f(L),{key:0,ref_key:"totalCharts",ref:M,class:"h-[32rem]"},null,512)):x("",!0),"IP TOP 10"===f(F)?(p(),d("div",E,[c(j,{column:f(U),data:f(z)},null,8,["column","data"])])):x("",!0)])])}}});export{Q as default};
