geekssl /

wstats

公开
main
wstats/public/assets/Spiders-1wZgVm2q.js
Spiders-1wZgVm2q.js10.3 KB
import{u as J,b as Q,e as V,r,p as X,w as Z,c as ee,j as e,S as K,q as D,h as d,x as se,z as x,d as p,T as H,v as E,A as te}from"./index-DS2B3OLK.js";import{B as g}from"./index-BNK0Nj_J.js";import{E as m}from"./index-dKmdA2E0.js";import{M as ie}from"./Modal-frvVG_x8.js";import{S as M}from"./index-Bj7oeOfx.js";import{T as I}from"./index-b2iqXj_X.js";import{T as L}from"./index-DhB1Ls4S.js";import{E as _,P as $}from"./EChart-DcWCF1N5.js";import"./IconTickCircle-Bbh_c2jr.js";import"./_baseDifference-D1QxGNC2.js";import"./index-CElfosix.js";import"./slice-s3-7cpgr.js";import"./object-DvQZmkoP.js";import"./index-R4PZyHYh.js";import"./echarts-CEICS1Jr.js";const ae=[7,30,90];function le(s){if(s=Number(s)||0,s<=0)return"—";const c=["B","KB","MB","GB","TB"];let a=0;for(;s>=1024&&a<c.length-1;)s/=1024,a++;return`${s>=10||a===0?Math.round(s):s.toFixed(1)} ${c[a]}`}const A={search:"spKindSearch",seo:"spKindSeo",ai:"spKindAi",social:"spKindSocial",monitor:"spKindMonitor",feed:"spKindFeed",tool:"spKindTool",other:"spKindOther"},re={search:"blue",seo:"purple",ai:"cyan",social:"green",monitor:"orange",feed:"violet",tool:"grey",other:"grey"};function ne(s,c){const a=s&&s.series||[];return{color:$,tooltip:{trigger:"axis"},legend:{top:0,icon:"roundRect",itemWidth:10,itemHeight:10},grid:{left:12,right:16,top:40,bottom:8,containLabel:!0},xAxis:{type:"category",boundaryGap:!1,data:(s&&s.days||[]).map(l=>String(l).slice(5)),axisLabel:{color:"#86909c"}},yAxis:{type:"value",splitLine:{lineStyle:{color:"#f0f1f3"}},axisLabel:{color:"#86909c"}},series:a.map(l=>({name:l.other?c("spSeriesOther"):l.spider,type:"line",stack:"s",smooth:!0,symbol:"none",areaStyle:{opacity:.14},lineStyle:{width:1.5},data:l.data||[]}))}}function oe(s,c){const a=s.filter(l=>l.hits>0);return{color:$,tooltip:{trigger:"item",formatter:"{b}: {c} ({d}%)"},legend:{orient:"vertical",right:8,top:"middle",icon:"circle",itemWidth:9,itemHeight:9},series:[{type:"pie",radius:["46%","70%"],center:["36%","50%"],avoidLabelOverlap:!0,itemStyle:{borderColor:"#fff",borderWidth:2},label:{show:!1},emphasis:{label:{show:!1}},data:a.map(l=>({name:c(A[l.kind]||"spKindOther"),value:l.hits}))}]}}function Te(){const{t:s}=J(),c=Q(),{site:a}=V(),[l,O]=r.useState(30),[t,R]=r.useState(null),[F,y]=r.useState(!1),[f,j]=r.useState(""),[P,h]=r.useState(!1),[u,v]=r.useState(""),[W,S]=X(),b=r.useCallback(async()=>{if(a){y(!0);try{const{start:i,end:o}=Z(l);R(await ee.spiders(a.id,i,o)),j("")}catch(i){j(i.message)}finally{y(!1)}}},[a,l]);r.useEffect(()=>{b()},[b]);const N=r.useMemo(()=>(t==null?void 0:t.spiders)||[],[t]),G=r.useMemo(()=>(t==null?void 0:t.kinds)||[],[t]),w=r.useMemo(()=>(t==null?void 0:t.pages)||[],[t]),n=(t==null?void 0:t.summary)||{},k=typeof location<"u"&&location.origin||"",T=String((t==null?void 0:t.snippet)&&t.snippet.php||"").replace(/\{host\}/g,k).replace(/\{site_key\}/g,String(a&&a.site_key||"")),C=`GET ${String((t==null?void 0:t.snippet)&&t.snippet.endpoint||"{host}/spider.php").replace(/\{host\}/g,k)}?ak=${String(a&&a.site_key||"")}&url=%2Fpage&ua=<URL-encoded UA>`,B=async(i,o)=>{if(!await te(i)){L.error(s("spCopyFail"));return}v(o),L.success(s("copied")),setTimeout(()=>v(z=>z===o?"":z),1600)},U=r.useMemo(()=>[{title:s("spColSpider"),dataIndex:"spider",render:(i,o)=>e.jsxs(K,{children:[e.jsx("span",{style:{fontWeight:600,fontFamily:"var(--wstat-mono)"},children:i}),e.jsx(D,{size:"small",color:re[o.kind]||"grey",children:s(A[o.kind]||"spKindOther")})]})},{title:s("spColHits"),dataIndex:"hits",width:100,sorter:(i,o)=>i.hits-o.hits,render:i=>d(i)},{title:s("spColPages"),dataIndex:"pages",width:100,render:i=>d(i)},{title:s("spColShare"),dataIndex:"share",width:160,render:i=>e.jsxs(K,{style:{width:"100%"},children:[e.jsx("span",{style:{width:42,textAlign:"right",fontSize:12},children:se(i)}),e.jsx("span",{style:{flex:1,height:6,background:"#f0f1f3",borderRadius:3,overflow:"hidden"},children:e.jsx("span",{style:{display:"block",height:"100%",width:`${Math.min(100,Number(i)||0)}%`,background:"#2a5cff"}})})]})},{title:s("spColLast"),dataIndex:"last_ts",width:120,render:i=>Number(i)>0?x(i,Math.floor(Date.now()/1e3),s):"—"}],[s]),q=r.useMemo(()=>[{title:s("spColUrl"),dataIndex:"url",render:i=>e.jsx("span",{style:{fontFamily:"var(--wstat-mono)",wordBreak:"break-all"},children:i})},{title:s("spColHits"),dataIndex:"hits",width:90,render:i=>d(i)},{title:s("spColSpiderCount"),dataIndex:"spiders",width:110,render:i=>d(i)},{title:s("spColLast"),dataIndex:"last_ts",width:120,render:i=>Number(i)>0?x(i,Math.floor(Date.now()/1e3),s):"—"}],[s]);if(!a)return e.jsx("div",{className:"page",children:e.jsx(m,{style:{marginTop:60},title:e.jsx(H.Title,{heading:5,children:s("noSiteHint")}),description:s("createHint"),children:e.jsx(p,{theme:"solid",onClick:()=>c("/sites"),children:s("goSites")})})});const Y=t&&t.table_ready===!1;return e.jsxs("div",{className:"page",ref:W,children:[e.jsxs("div",{className:"toolbar",children:[e.jsx(H.Title,{heading:5,style:{margin:0},children:s("spTitle")}),e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx(p,{size:"small",onClick:()=>h(!0),children:s("spSnippetBtn")}),ae.map(i=>e.jsx(p,{size:"small",theme:l===i?"solid":"borderless",onClick:()=>O(i),children:s(i===7?"last7":i===30?"last30":"last90")},i))]})]}),f&&e.jsx(g,{type:"danger",style:{marginBottom:12},description:e.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",fontFamily:"var(--wstat-mono)",fontSize:12},children:f})}),Y&&e.jsx(g,{type:"warning",style:{marginBottom:12},description:e.jsx("div",{style:{whiteSpace:"pre-wrap",lineHeight:1.8},children:s("spNeedUpgrade")})}),t&&t.enabled===!1&&e.jsx(g,{type:"info",style:{marginBottom:12},description:s("spDisabled")}),e.jsxs("div",{className:"stat-grid",children:[e.jsxs("div",{className:"stat-card",children:[e.jsx("div",{className:"stat-label",children:s("spHits")}),e.jsx("div",{className:"stat-value",children:d(n.hits)}),e.jsx("div",{className:"stat-sub",children:n.last_spider?`${s("spMostActive")}: ${n.last_spider}`:"—"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("div",{className:"stat-label",children:s("spPages")}),e.jsx("div",{className:"stat-value",children:d(n.pages)}),e.jsxs("div",{className:"stat-sub",children:[s("spActiveDays")," ",d(n.days)," / ",d(n.range_days)]})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("div",{className:"stat-label",children:s("spSpiders")}),e.jsx("div",{className:"stat-value",children:d(n.spiders)}),e.jsx("div",{className:"stat-sub",children:t!=null&&t.range?`${t.range.start} ~ ${t.range.end}`:""})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("div",{className:"stat-label",children:s("spBytes")}),e.jsx("div",{className:"stat-value",children:le(n.bytes)}),e.jsx("div",{className:"stat-sub",children:n.last_ts?`${s("spLastCrawl")} ${x(n.last_ts,Math.floor(Date.now()/1e3),s)}`:s("spNever")})]})]}),F&&!t?e.jsx(M,{active:!0,placeholder:e.jsx(M.Paragraph,{rows:6}),loading:!0}):t?N.length===0?e.jsxs("div",{className:"card",style:{padding:"18px 20px"},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:6},children:s("spEmptyTitle")}),e.jsx("div",{style:{fontSize:13,color:"#86909c",lineHeight:1.8},children:s("spEmptyDesc")}),e.jsx("div",{style:{marginTop:12},children:e.jsx(p,{theme:"solid",size:"small",onClick:()=>h(!0),children:s("spSnippetBtn")})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:[e.jsxs("div",{className:"chart-box",children:[e.jsx("div",{className:"card-title",children:s("spTrendTitle")}),e.jsx(_,{option:ne(t.trend,s),height:280})]}),e.jsxs("div",{className:"chart-box",children:[e.jsx("div",{className:"card-title",children:s("spKindTitle")}),e.jsx(_,{option:oe(G,s),height:280})]})]}),e.jsxs("div",{className:"card",style:{padding:0,overflow:"hidden",marginBottom:16},children:[e.jsx("div",{className:"card-title",style:{padding:"14px 16px 6px"},children:s("spRankTitle")}),e.jsx(I,{columns:U,dataSource:N,rowKey:"spider",pagination:!1,size:"small",scroll:E(S,820),empty:e.jsx(m,{description:s("noData")})})]}),e.jsxs("div",{className:"card",style:{padding:0,overflow:"hidden",marginBottom:16},children:[e.jsx("div",{className:"card-title",style:{padding:"14px 16px 6px"},children:s("spPagesTitle")}),e.jsx(I,{columns:q,dataSource:w,rowKey:"url",pagination:w.length>15?{pageSize:15,size:"small"}:!1,size:"small",scroll:E(S,780),empty:e.jsx(m,{description:s("noData")})})]}),e.jsx("div",{className:"card",style:{padding:"14px 20px"},children:e.jsxs("div",{style:{fontSize:13,color:"#86909c",lineHeight:1.8},children:[e.jsxs("div",{style:{marginBottom:4},children:[e.jsx(D,{color:"blue",size:"small",children:s("spNoteTag")}),e.jsx("span",{style:{marginLeft:8},children:s("spNote1")})]}),e.jsx("div",{children:s("spNote2")}),e.jsx("div",{style:{marginTop:6},children:e.jsx(p,{size:"small",theme:"borderless",onClick:()=>h(!0),children:s("spSnippetBtn")})})]})})]}):e.jsx(m,{description:s("noData"),style:{margin:"40px 0"}}),e.jsx(ie,{title:s("spSnippetTitle"),visible:P,onCancel:()=>h(!1),footer:null,width:720,centered:!0,children:e.jsxs("div",{className:"modal-desc",children:[e.jsx("div",{style:{fontSize:13,color:"#4e5969",lineHeight:1.8,marginBottom:10},children:s("spSnippetWhy")}),e.jsx("div",{className:"vf-step",children:s("spSnippetStep1")}),e.jsx("div",{style:{fontSize:12,color:"#86909c",lineHeight:1.7,marginBottom:6},children:s("spSnippetStep1Desc")}),e.jsx("pre",{className:"code-block",style:{background:"#0f172a",color:"#e2e8f0",maxHeight:260,overflow:"auto",userSelect:"text"},children:T}),e.jsxs("div",{className:"vf-field-row",children:[e.jsx("span",{className:"vf-field",children:s("spSnippetPhp")}),e.jsx(p,{size:"small",theme:"borderless",onClick:()=>B(T,"php"),children:s(u==="php"?"copied":"copy")})]}),e.jsx("div",{className:"vf-step",children:s("spSnippetStep2")}),e.jsx("div",{style:{fontSize:12,color:"#86909c",lineHeight:1.7,marginBottom:6},children:s("spSnippetStep2Desc")}),e.jsx("pre",{className:"code-block",style:{userSelect:"text",wordBreak:"break-all"},children:C}),e.jsxs("div",{className:"vf-field-row",children:[e.jsx("span",{className:"vf-field",children:s("spSnippetHttp")}),e.jsx(p,{size:"small",theme:"borderless",onClick:()=>B(C,"http"),children:s(u==="http"?"copied":"copy")})]}),e.jsx("div",{className:"vf-step",children:s("spSnippetStep3")}),e.jsx("div",{style:{fontSize:12,color:"#86909c",lineHeight:1.8},children:s("spSnippetStep3Desc")})]})})]})}export{Te as default};