1import{r as e,j as s}from"./vendor-react-DejgYtBM.js";import{m as t,f as a,B as l,x as i,s as d,t as r,S as n,y as o,E as c,L as x}from"./vendor-semi-D8d7bTtM.js";import{u as p,S as h,$ as y,a0 as g,aG as _,A as m,s as u,U as j,J as f}from"./index-BeIIFw6E.js";import{R as w}from"./vendor-icons-EJvJ5X-w.js";import"./vendor-motion-Chfy_MiU.js";const{Text:v,Title:N}=a,T=()=>{const{t:a}=p(),[c]=e.useContext(h),x=y()&&!g(),j=!x&&(_()||g()),f=_()&&!x,T=!x&&(_()||g()||y()),b=g(),[F,z]=e.useState("sub"),[S,C]=e.useState({}),[$,k]=e.useState(null),[I,A]=e.useState(null),[D,L]=e.useState({today_top_up:!x,today_consumption:!x,today_registrations:!x,today_agent_sites:T,yesterday_top_up:!x,yesterday_consumption:!x,yesterday_registrations:!x,yesterday_agent_sites:T,month_top_up:j,last_month_top_up:j,top_channel_usage:!x,top_error_models:!x,top_model_usage:!x,top_user_usage:!0,top_group_usage:b}),[B,E]=e.useState(!1),M=e=>{if(!e)return null;const s=e instanceof Date?e:new Date(e);return`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`},O=e=>{const s=c?.status?.currency_type||"USD",t=c?.status?.usd_exchange_rate||7.3,a=c?.status?.custom_currency_exchange_rate||1;if("TOKENS"===s)return`${e.toFixed(2)}`;let l="$",i=e;return"CNY"===s?(i=e*t,l="Â¥"):"CUSTOM"===s&&(i=e*a,l=c?.status?.custom_currency_symbol||"¤"),`${l}${i.toFixed(2)}`},R=async(e=null)=>{const s=(x?["top_user_usage","top_error_models"]:["today_top_up","today_consumption","today_registrations",...T?["today_agent_sites"]:[],"yesterday_top_up","yesterday_consumption","yesterday_registrations",...T?["yesterday_agent_sites"]:[],...j?["month_top_up","last_month_top_up"]:[],"top_error_models","top_channel_usage","top_model_usage","top_user_usage",...b?["top_group_usage"]:[]]).map(async s=>{try{let t=`/api/user/statistics?type=${s}`;f&&(t+=`&scope=${F}`),e&&(t+=`&date=${e}`);const l=await m.get(t);l.data.success?C(e=>{const t={...e,[s]:l.data.data[s]};return"today_top_up"===s&&(t.today_main_top_up=l.data.data.today_main_top_up,t.today_agent_top_up=l.data.data.today_agent_top_up),"yesterday_top_up"===s&&(t.yesterday_main_top_up=l.data.data.yesterday_main_top_up,t.yesterday_agent_top_up=l.data.data.yesterday_agent_top_up),t}):u(`${s}: ${l.data.message||a("è·åæ°æ®å¤±è´¥")}`)}catch(t){u(`${s}: ${a("è·åæ°æ®å¤±è´¥")}`)}finally{L(e=>({...e,[s]:!1}))}});await Promise.all(s)};e.useEffect(()=>{R(I?M(I):null)},[F]);const U=(e,s)=>0===s?e>0?100:0:((e-s)/s*100).toFixed(2),W=e=>{const t=e+1,a={1:{bg:"#FFF7E6",color:"#D4A017",border:"#FADB14"},2:{bg:"#F0F0F0",color:"#8C8C8C",border:"#BFBFBF"},3:{bg:"#FFF1E6",color:"#CD7F32",border:"#FFBB96"}}[t]||{bg:"#FAFAFA",color:"#999",border:"#E8E8E8"};return s.jsx("div",{style:{width:24,height:24,borderRadius:"50%",display:"inline-flex",alignItems:"center",justifyContent:"center",backgroundColor:a.bg,border:`1px solid ${a.border}`,color:a.color,fontSize:12,fontWeight:t<=3?700:500,lineHeight:1},children:t})};if(Object.values(D).every(e=>!e)&&0===Object.keys(S).length)return s.jsx(t,{className:"!rounded-2xl",shadows:"always",children:s.jsxs("div",{className:"text-center p-8",children:[s.jsx(v,{type:"secondary",children:a("ææ æ°æ®")}),s.jsx(l,{size:"small",className:"!rounded-full ml-4",icon:s.jsx(w,{size:16}),onClick:R,children:a("éè¯")}
1)]})});const Y=S.today_top_up||0,G=S.yesterday_top_up||0,H=S.today_main_top_up||0,J=S.yesterday_main_top_up||0,K=S.today_agent_top_up||0,P=S.yesterday_agent_top_up||0,q=S.today_consumption||0,Q=S.yesterday_consumption||0,V=S.today_registrations||0,X=S.yesterday_registrations||0,Z=S.today_agent_sites||0,ee=S.yesterday_agent_sites||0,se=S.month_top_up??0,te=S.last_month_top_up??0,ae=I?new Date(I).toLocaleDateString("zh-CN",{month:"numeric",day:"numeric"}):a("仿¥"),le=I?new Date(new Date(I).getTime()-864e5).toLocaleDateString("zh-CN",{month:"numeric",day:"numeric"}):a("æ¨æ¥");return s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsx(t,{className:"!rounded-2xl",shadows:"always",style:{padding:"16px"},children:s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"},children:[s.jsxs(v,{type:"secondary",children:[a("éæ©æ¥æ"),":"]}),s.jsx(i,{value:$,onChange:e=>k(e),placeholder:a("é»è®¤ä»å¤©"),style:{width:"200px"},format:"yyyy-MM-dd"}),s.jsx(l,{theme:"solid",onClick:()=>{L({today_top_up:!x,today_consumption:!x,today_registrations:!x,today_agent_sites:T,yesterday_top_up:!x,yesterday_consumption:!x,yesterday_registrations:!x,yesterday_agent_sites:T,month_top_up:j,last_month_top_up:j,top_channel_usage:!x,top_error_models:!x,top_model_usage:!x,top_user_usage:!0,top_group_usage:b}),A($);const e=M($);R(e)},type:"primary",children:a("æ¥è¯¢")}),f&&s.jsxs(d,{type:"button",value:F,onChange:e=>z(e.target.value),children:[s.jsx(r,{value:"direct",children:a("ç´å±ç¨æ·")}),s.jsx(r,{value:"sub",children:a("ä¸çº§")})]}),s.jsx(v,{type:"tertiary",size:"small",children:a($?"æ¥è¯¢é宿¥æååä¸å¤©çæ°æ®":"é»è®¤æ¥è¯¢ä»å¤©åæ¨å¤©çæ°æ®")})]})}),!x&&s.jsxs("div",{className:"grid grid-cols-2 gap-4 "+(y()?"md:grid-cols-3 lg:grid-cols-6":"md:grid-cols-4"),children:[s.jsx(t,{className:"!rounded-2xl",shadows:"always",style:{padding:"20px"},children:D.today_top_up||D.yesterday_top_up?s.jsx(n,{loading:!0,active:!0,placeholder:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(n.Title,{style:{width:"60px",height:"14px"}}),s.jsx(n.Title,{style:{width:"80px",height:"28px"}}),s.jsx(n.Title,{style:{width:"120px",height:"12px"}})]})}):s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs(v,{type:"secondary",size:"small",children:[ae,y()?a("æ»å
å¼"):a("å
å¼")]}),s.jsxs(N,{heading:3,style:{margin:0,color:"#1890ff"},children:["Â¥",Y.toFixed(2)]}),s.jsxs(v,{type:"tertiary",size:"small",children:[le,": Â¥",G.toFixed(2),s.jsxs(v,{style:{color:U(Y,G)>=0?"#52c41a":"#ff4d4f",marginLeft:"4px"},children:[U(Y,G)>=0?"+":"",U(Y,G),"%"]})]})]})}),j&&s.jsx(t,{className:"!rounded-2xl",shadows:"always",style:{padding:"20px"},children:D.month_top_up||D.last_month_top_up?s.jsx(n,{loading:!0,active:!0,placeholder:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(n.Title,{style:{width:"80px",height:"14px"}}),s.jsx(n.Title,{style:{width:"80px",height:"28px"}}),s.jsx(n.Title,{style:{width:"120px",height:"12px"}})]})}):s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(v,{type:"secondary",size:"small",children:a("æ¬æå
å¼")}),s.jsxs(N,{heading:3,style:{margin:0,color:"#722ed1"},children:["Â¥",se.toFixed(2)]}),s.jsxs(v,{type:"tertiary",size:"small",children:[a("䏿"),": Â¥",te.toFixed(2)]})]})}),y()&&s.jsx(t,{className:"!rounded-2xl",shadows:"always",style:{padding:"20px"},children:D.today_top_up||D.yesterday_top_up?s.jsx(n,{loading:!0,active:!0,placeholder:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(n.Title,{style:{width:"60px",height:"14px"}}),s.jsx(n.Title,{style:{width:"80px",height:"28px"}}),s.jsx(n.Title,{style:{width:"120px",height:"12px"}})]})}):s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs(v,{type:"secondary",size:"small",children:[ae,a("主ç«å
å¼")]}),s.jsxs(N,{heading:3,style:{margin:0,color:"#13c2c2"},children:["Â¥",H.toFixed(2)]}),s.jsxs(v,{type:"tertiary",size:"small",children:[le,": Â¥",J.toFixed(2),s.jsxs(v,{style:{color:U(H,J)>=0?"#52c41a":"#ff4d4f",marginLeft:"4px"},children:[U(H,J)>=0?"+":"",U(H,J),"%"]})]})]})}),y()&&s.jsx(t,{className:"!rounded-2xl",shadows:"always",style:{padding:"20px"},children:D.today_top_up||D.yesterday_top_up?s.jsx(n,{loading:!0,active:!0,placeholder:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(n.Title,{style:{width:"60px",height:"14px"}}),s.jsx(n.Title,{style:{width:"80px",height:"28px"}}),s.jsx(n.Title,{style:{width:"120px",height:"12px"}})]})}):s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs(v,{type:"secondary",size:"small",children:[ae,a("代çç«å
å¼")]}),s.jsxs(N,{heading:3,style:{margin:0,color:"#eb2f96"},children:["Â¥",K.toFixed(2)]}),s.jsxs(v,{type:"tertiary",size:"small",children:[le,": Â¥",P.toFixed(2),s.jsxs(v,{style:{color:U(K,P)>=0?"#52c41a":"#ff4d4f",marginLeft:"4px"},children:[U(K,P)>=0?"+":"",U(K,P),"%"]})]})]})}),s.jsx(t,{className:"!rounded-2xl",shadows:"always",style:{padding:"20px"},children:D.today_consumption||D.yesterday_consumption?s.jsx(n,{loading:!0,active:!0,placeholder:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(n.Title,{style:{width:"60px",height:"14px"}}),s.jsx(n.Title,{style:{width:"80px",height:"28px"}}),s.jsx(n.Title,{style:{width:"120px",height:"12px"}})]})}):s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs(v,{type:"secondary",size:"small",children:[ae,a("æ¶è´¹")]}),s.jsx(N,{heading:3,style:{margin:0,color:"#52c41a"},children:O(q)}),s.jsxs(v,{type:"tertiary",size:"small",children:[le,": ",O(Q),s.jsxs(v,{style:{color:U(q,Q)>=0?"#52c41a":"#ff4d4f",marginLeft:"4px"},children:[U(q,Q)>=0?"+":"",U(q,Q),"%"]})]})]})}),s.jsx(t,{className:"!rounded-2xl",shadows:"always",style:{padding:"20px"},children:D.today_registrations||D.yesterday_registrations?s.jsx(n,{loading:!0,active:!0,placeholder:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(n.Title,{style:{width:"60px",height:"14px"}}),s.jsx(n.Title,{style:{width:"80px",height:"28px"}}),s.jsx(n.Title,{style:{width:"120px",height:"12px"}})]})}):s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs(v,{type:"secondary",size:"small",children:[ae,a("注å")]}),s.jsx(N,{heading:3,style:{margin:0,color:"#722ed1"},children:V}),s.jsxs(v,{type:"tertiary",size:"small",children:[le,": ",X,s.jsxs(v,{style:{color:U(V,X)>=0?"#52c41a":"#ff4d4f",marginLeft:"4px"},children:[U(V,X)>=0?"+":"",U(V,X),"%"]})]})]})}),T&&s.jsx(t,{className:"!rounded-2xl",shadows:"always",style:{padding:"20px"},children:D.today_agent_sites||D.yesterday_agent_sites?s.jsx(n,{loading:!0,active:!0,placeholder:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(n.Title,{style:{width:"60px",height:"14px"}}),s.jsx(n.Title,{style:{width:"80px",height:"28px"}}),s.jsx(n.Title,{style:{width:"120px",height:"12px"}})]})}):s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs(v,{type:"secondary",size:"small",children:[ae,a("ä»£çæ³¨å")]}),s.jsx(N,{heading:3,style:{margin:0,color:"#fa8c16"},children:Z}),s.jsxs(v,{type:"tertiary",size:"small",children:[le,": ",ee,s.jsxs(v,{style:{color:U(Z,ee)>=0?"#52c41a":"#ff4d4f",marginLeft:"4px"},children:[U(Z,ee)>
1=0?"+":"",U(Z,ee),"%"]})]})]})})]}),!x&&y()&&s.jsx(t,{className:"!rounded-2xl",shadows:"always",style:{padding:"12px 16px"},children:s.jsxs(v,{type:"tertiary",size:"small",children:[a("å
弿°æ®è¯´æ"),": ",a("æ»å
å¼")," = ",a("主ç«å
å¼")," + ",a("代çç«å
å¼"),"ã",a("主ç«å
弿æ ä¸çº§ä»£ççç¨æ·å
å¼ï¼ä»£çç«å
弿æä¸çº§ä»£ççç¨æ·å
å¼ã")]})}),s.jsxs("div",{className:"grid grid-cols-1 gap-4 "+(x?"lg:grid-cols-2":b?"lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-5":"lg:grid-cols-2 xl:grid-cols-4"),children:[!x&&s.jsx(t,{className:"!rounded-2xl",shadows:"always",title:a("模åæè¡"),children:D.top_model_usage?s.jsx(n,{loading:!0,active:!0,placeholder:s.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((e,t)=>s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx(n.Title,{style:{width:"80px",height:"14px"}}),s.jsx(n.Title,{style:{width:"60px",height:"14px"}})]},t))})}):s.jsx(o,{dataSource:S.top_model_usage?.slice(0,10)||[],columns:[{title:"#",key:"rank",width:50,align:"center",render:(e,s,t)=>W(t)},{title:a("模å"),dataIndex:"model_name"},{title:a("使ç¨é"),dataIndex:"usage",render:e=>O(e||0)}],pagination:!1,size:"small"})}),!x&&s.jsx(t,{className:"!rounded-2xl",shadows:"always",title:a("æ¸ éæè¡"),children:D.top_channel_usage?s.jsx(n,{loading:!0,active:!0,placeholder:s.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((e,t)=>s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx(n.Title,{style:{width:"80px",height:"14px"}}),s.jsx(n.Title,{style:{width:"60px",height:"14px"}})]},t))})}):s.jsx(o,{dataSource:S.top_channel_usage?.slice(0,10)||[],columns:[{title:"#",key:"rank",width:50,align:"center",render:(e,s,t)=>W(t)},{title:a("æ¸ é"),dataIndex:"channel_name"},{title:a("使ç¨é"),dataIndex:"usage",render:e=>O(e||0)}],pagination:!1,size:"small"})}),s.jsx(t,{className:"!rounded-2xl",shadows:"always",title:a("ç¨æ·æè¡"),children:D.top_user_usage?s.jsx(n,{loading:!0,active:!0,placeholder:s.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((e,t)=>s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx(n.Title,{style:{width:"80px",height:"14px"}}),s.jsx(n.Title,{style:{width:"60px",height:"14px"}})]},t))})}):x?s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:0},children:0===(S.top_user_usage?.slice(0,10)||[]).length?s.jsx("div",{style:{textAlign:"center",padding:"24px 0"},children:s.jsx(v,{type:"tertiary",children:a("ææ æ°æ®")})}):(S.top_user_usage?.slice(0,10)||[]).map((e,t)=>s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"8px 12px",borderRadius:8,backgroundColor:t%2==0?"hsl(var(--foreground) / 0.02)":"transparent",transition:"background-color 0.2s"},children:[W(t),s.jsx(v,{ellipsis:{showTooltip:!0},style:{flex:1,fontSize:14},children:e.username})]},e.username||t))}):s.jsx(o,{dataSource:S.top_user_usage?.slice(0,10)||[],columns:[{title:"#",key:"rank",width:50,align:"center",render:(e,s,t)=>W(t)},{title:a("ç¨æ·"),dataIndex:"username"},{title:a("使ç¨é"),dataIndex:"usage",render:e=>O(e||0)}],pagination:!1,size:"small"})}),b&&s.jsx(t,{className:"!rounded-2xl",shadows:"always",title:a("æ¸ éåç»æè¡"),children:D.top_group_usage?s.jsx(n,{loading:!0,active:!0,placeholder:s.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((e,t)=>s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx(n.Title,{style:{width:"80px",height:"14px"}}),s.jsx(n.Title,{style:{width:"60px",height:"14px"}})]},t))})}):s.jsx(o,{dataSource:S.top_group_usage?.slice(0,10)||[],columns:[{title:"#",key:"rank",width:50,align:"center",render:(e,s,t)=>W(t)},{title:a("æ¸ éåç»"),dataIndex:"group_name"},{title:a("使ç¨é"),dataIndex:"usage",render:e=>O(e||0)}],pagination:!1,size:"small"})}),s.jsx(t,{className:"!rounded-2xl",shadows:"always",title:s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s.jsx("span",{children:a("é误模åæè¡")}),s.jsx(l,{size:"small",icon:s.jsx(w,{size:16}),onClick:async()=>
1{if(!B){E(!0),L(e=>({...e,top_error_models:!0}));try{let e="/api/user/statistics?type=top_error_models";f&&(e+=`&scope=${F}`),I&&(e+=`&date=${M(I)}`);const s=await m.get(e);s.data.success?C(e=>({...e,top_error_models:s.data.data.top_error_models})):u(`${a("è·åé误模åæè¡å¤±è´¥")}: ${s.data.message||a("è·åæ°æ®å¤±è´¥")}`)}catch(e){u(a("è·åé误模åæè¡å¤±è´¥"))}finally{L(e=>({...e,top_error_models:!1})),E(!1)}}},loading:B,disabled:B,theme:"borderless",type:"tertiary",style:{marginRight:"-8px"},children:a("å·æ°")})]}),children:D.top_error_models?s.jsx(n,{loading:!0,active:!0,placeholder:s.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((e,t)=>s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx(n.Title,{style:{width:"80px",height:"14px"}}),s.jsx(n.Title,{style:{width:"60px",height:"14px"}})]},t))})}):S.top_error_models?s.jsx(o,{dataSource:S.top_error_models?.slice(0,10)||[],columns:[{title:"#",key:"rank",width:50,align:"center",render:(e,s,t)=>W(t)},{title:a("模å"),dataIndex:"model_name"},{title:a("é误次æ°"),dataIndex:"error_count",render:e=>s.jsx(v,{style:{color:"#ff4d4f"},children:e||0})}],pagination:!1,size:"small"}):s.jsx("div",{style:{textAlign:"center",padding:"40px 20px"},children:s.jsx(v,{type:"tertiary",children:a("ç¹å»å·æ°æé®å è½½æ°æ®")})})})]})]})},{Text:b,Title:F}=a,{Content:z}=x,S=()=>{const{t:a}=p(),[l]=e.useContext(j);return g()||y()||f()?s.jsx("div",{className:"",children:s.jsx("div",{className:"bg-transparent min-h-screen p-4",children:s.jsxs("div",{className:"max-w-7xl mx-auto",children:[s.jsx(F,{heading:2,className:"!text-foreground",style:{marginBottom:"1rem"},children:a("管ç颿¿")}),s.jsx(T,{})]})})}):s.jsx("div",{className:"bg-transparent min-h-screen flex items-center justify-center p-4",children:s.jsx(t,{className:"!rounded-2xl !bg-card !border-border",shadows:"always",style:{maxWidth:"400px"},children:s.jsx(c,{title:a("æéä¸è¶³"),description:a("æ¨æ²¡æè®¿é®ç®¡ç颿¿çæé")})})})},C=()=>s.jsx(S,{});export{C as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.