geekssl /

wstats

公开
main
wstats/public/assets/Sources-D8nPHyPA.js
Sources-D8nPHyPA.js8.8 KB
import{u as _,b as G,e as U,r,w as P,c as V,j as e,d as m,T as y,S as B,x as u,h as o,t as Y}from"./index-DS2B3OLK.js";import{B as q}from"./index-BNK0Nj_J.js";import{E as p}from"./index-dKmdA2E0.js";import{S as D}from"./index-Bj7oeOfx.js";import{T as v}from"./index-b2iqXj_X.js";import{E as R}from"./EChart-DcWCF1N5.js";import{E as J}from"./ExportButton-CoqnqODF.js";import{e as H}from"./engines-5vW3I485.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";import"./index-DhB1Ls4S.js";const Q=[7,30,90],j=["direct","search","social","link","paid","utm","internal"],h={direct:"#86909c",search:"#2a5cff",social:"#00b42a",link:"#ff7d00",paid:"#f53f3f",utm:"#722ed1",internal:"#00b2ff"};function x(s,d){return s({direct:"chDirect",search:"chSearch",social:"chSocial",link:"chLink",paid:"chPaid",utm:"chUtm",internal:"chInternal"}[d]||"chOther")}function X(s,d){const l=s.filter(a=>a.pv>0).map(a=>({name:x(d,a.type),value:a.pv}));return{color:j.filter(a=>s.find(c=>c.type===a&&c.pv>0)).map(a=>h[a]),tooltip:{trigger:"item",formatter:"{b}: {c} ({d}%)"},legend:{orient:"vertical",right:10,top:"middle",icon:"circle",itemWidth:9,itemHeight:9},series:[{type:"pie",radius:["46%","70%"],center:["38%","50%"],avoidLabelOverlap:!0,itemStyle:{borderColor:"#fff",borderWidth:2},label:{show:!1},emphasis:{label:{show:!1}},data:l}]}}function Z(s,d){return{color:j.map(l=>h[l]),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.days.map(l=>l.slice(5)),axisLabel:{color:"#86909c"}},yAxis:{type:"value",splitLine:{lineStyle:{color:"#f0f1f3"}},axisLabel:{color:"#86909c"}},series:j.map(l=>({name:x(d,l),type:"line",stack:"s",smooth:!0,symbol:"none",areaStyle:{opacity:.14},lineStyle:{width:1.5},data:s.data&&s.data[l]||[]}))}}function fe(){var z,E;const{t:s,lang:d}=_(),l=G(),{site:a}=U(),[c,L]=r.useState(30),[i,W]=r.useState(null),[A,b]=r.useState(!1),[w,S]=r.useState(""),C=r.useCallback(async()=>{if(a){b(!0);try{const{start:t,end:f}=P(c);W(await V.sources(a.id,t,f)),S("")}catch(t){S(t.message)}finally{b(!1)}}},[a,c]);if(r.useEffect(()=>{C()},[C]),!a)return e.jsx("div",{className:"page",children:e.jsx(p,{style:{marginTop:60},title:e.jsx(y.Title,{heading:5,children:s("noSiteHint")}),description:s("createHint"),children:e.jsx(m,{theme:"solid",onClick:()=>l("/sites"),children:s("goSites")})})});const g=r.useMemo(()=>(i==null?void 0:i.channels)||[],[i]),F=r.useMemo(()=>(i==null?void 0:i.referrers)||[],[i]),k=r.useMemo(()=>(i==null?void 0:i.engines)||[],[i]),N=r.useMemo(()=>(i==null?void 0:i.terms)||[],[i]),T=(i==null?void 0:i.no_kw_pv)||0,n=(i==null?void 0:i.total_pv)||0,I=r.useMemo(()=>({title:s("srcColShare"),dataIndex:"pv",width:220,render:(t,f)=>{const M=n>0?t/n*100:0;return e.jsxs(B,{style:{width:"100%"},children:[e.jsx("span",{style:{width:42,textAlign:"right",fontSize:12},children:u(M)}),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,M)}%`,background:h[f.type]||"#2a5cff"}})})]})}}),[s,n]),K=r.useMemo(()=>[{title:s("srcColChannel"),dataIndex:"type",render:t=>e.jsxs(B,{children:[e.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:h[t]}}),x(s,t)]})},{title:s("srcColPv"),dataIndex:"pv",width:90,render:t=>o(t)},I],[s,n,I]),$=r.useMemo(()=>[{title:s("srcColHost"),dataIndex:"host",render:t=>e.jsx("span",{style:{fontFamily:"var(--wstat-mono)"},children:t})},{title:s("srcColPv"),dataIndex:"pv",width:90,render:t=>o(t)},{title:s("srcColShare"),dataIndex:"pv",width:90,render:t=>u(n>0?t/n*100:0)}],[s,n]),O=r.useMemo(()=>[{title:s("srcColEngine"),dataIndex:"engine",width:110,render:t=>H(t,d)},{title:s("srcColKeyword"),dataIndex:"kw",render:t=>e.jsx("span",{style:{fontFamily:"var(--wstat-mono)"},children:t})},{title:s("srcColPv"),dataIndex:"pv",width:80,render:t=>o(t)},{title:s("srcColUv"),dataIndex:"uv",width:80,render:t=>o(t)}],[s,d]);return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"toolbar",children:[e.jsx(y.Title,{heading:5,style:{margin:0},children:s("sources")}),e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx(J,{siteId:a==null?void 0:a.id,items:[{kind:"channels",label:s("expChannels")},{kind:"referrers",label:s("expReferrers")},{kind:"daily",label:s("expDaily")}],params:()=>P(c)}),Q.map(t=>e.jsx(m,{size:"small",theme:c===t?"solid":"borderless",onClick:()=>L(t),children:s(t===7?"last7":t===30?"last30":"last90")},t))]})]}),w&&e.jsx(q,{type:"danger",style:{marginBottom:12},description:e.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",fontFamily:"var(--wstat-mono)",fontSize:12},children:w})}),e.jsxs("div",{className:"stat-grid",children:[e.jsxs("div",{className:"stat-card",children:[e.jsx("div",{className:"stat-label",children:s("srcPvTotal")}),e.jsx("div",{className:"stat-value",children:o(n)}),e.jsxs("div",{className:"stat-sub",children:[(z=i==null?void 0:i.range)==null?void 0:z.start," ~ ",(E=i==null?void 0:i.range)==null?void 0:E.end]})]}),g.filter(t=>t.pv>0).slice(0,3).map(t=>e.jsxs("div",{className:"stat-card",children:[e.jsxs("div",{className:"stat-label",children:[e.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:h[t.type],marginRight:6}}),x(s,t.type)]}),e.jsx("div",{className:"stat-value",children:o(t.pv)}),e.jsx("div",{className:"stat-sub",children:u(n>0?t.pv/n*100:0)})]},t.type))]}),A&&!i?e.jsx(D,{active:!0,placeholder:e.jsx(D.Paragraph,{rows:6}),loading:!0}):i?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("srcChannelTitle")}),e.jsx(R,{option:X(g,s),height:280})]}),e.jsxs("div",{className:"chart-box",children:[e.jsx("div",{className:"card-title",children:s("srcTrendTitle")}),e.jsx(R,{option:Z(i.trend,s),height:280})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:[e.jsxs("div",{className:"card",style:{padding:0,overflow:"hidden"},children:[e.jsx("div",{className:"card-title",style:{padding:"14px 16px 6px"},children:s("srcChannelTable")}),e.jsx(v,{columns:K,dataSource:g,rowKey:"type",pagination:!1,size:"small",empty:e.jsx(p,{description:s("noData")})})]}),e.jsxs("div",{className:"card",style:{padding:0,overflow:"hidden"},children:[e.jsx("div",{className:"card-title",style:{padding:"14px 16px 6px"},children:s("srcReferrers")}),e.jsx(v,{columns:$,dataSource:F,rowKey:"host",pagination:!1,size:"small",empty:e.jsx(p,{description:s("noData")})})]})]}),e.jsxs("div",{className:"card",style:{padding:0,overflow:"hidden",marginBottom:16},children:[e.jsxs("div",{className:"card-title",style:{padding:"14px 16px 6px",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsx("span",{children:s("srcSearchTitle")}),e.jsx(m,{size:"small",theme:"borderless",onClick:()=>l("/engines"),children:s("srcGoEngines")})]}),k.length===0?e.jsx(p,{description:s("noData"),style:{margin:"16px 0 24px"}}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,padding:"4px 16px 12px"},children:k.map(t=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"3px 10px",borderRadius:999,fontSize:12,background:"#f0f5ff",border:"1px solid #d6e4ff"},children:[e.jsx("span",{style:{fontWeight:600},children:H(t.engine,d)}),e.jsxs("span",{style:{color:"#86909c"},children:[o(t.pv)," PV · ",o(t.uv)," UV"]})]},t.engine))}),e.jsx(v,{columns:O,dataSource:N,rowKey:t=>`${t.engine}|${t.kw}`,pagination:N.length>10?{pageSize:10,size:"small"}:!1,size:"small",empty:e.jsx(p,{description:s("srcSearchNone")})}),e.jsxs("div",{style:{padding:"8px 16px 14px",fontSize:12,color:"#86909c",lineHeight:1.7},children:[s("srcSearchHint"),T>0?`(${s("srcSearchNotProvided")} ${o(T)} PV)`:""]})]})]}),e.jsx("div",{className:"card",style:{padding:"18px 20px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,marginBottom:6},children:s("srcAdsMovedTitle")}),e.jsx("div",{style:{fontSize:13,color:"#86909c",lineHeight:1.7},children:s("srcAdsMovedDesc")})]}),e.jsx(m,{theme:"solid",size:"small",onClick:()=>l("/ads"),children:s("srcAdsMovedBtn")})]})}),e.jsxs(y.Text,{type:"tertiary",style:{fontSize:12,display:"block",marginTop:16},children:[a.name," · ",a.domain," · ",s("range"),": ",i.range.start," ~ ",i.range.end,"(",Y(),") · ",s("source"),": direct/search/social/link/paid/utm"]})]}):e.jsx(p,{description:s("noData"),style:{margin:"40px 0"}})]})}export{fe as default};