mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
2 lines
26 KiB
JavaScript
2 lines
26 KiB
JavaScript
import{E as mt}from"./element-plus-B8Fs_0jW.js";import{aR as pt,r as A,c as yt,aW as ft,o as ot,q as gt,D as Y,x as D,z as t,P as y,u as o,O as _,L as H,Q as it,ac as dt,C as V,R as xt,y as w}from"./vue-vendor-CKToUHZx.js";import{a as N,_ as ht}from"./index-HsvoyPKA.js";import{s as nt}from"./toast-BvwA7Mwb.js";import{C as lt}from"./chart-Cor9iTVD.js";import"./vendor-BDiMbLwQ.js";const bt=pt("dashboard",()=>{const G=A(!1),B=A({totalApiKeys:0,activeApiKeys:0,totalAccounts:0,activeAccounts:0,rateLimitedAccounts:0,todayRequests:0,totalRequests:0,todayTokens:0,todayInputTokens:0,todayOutputTokens:0,totalTokens:0,totalInputTokens:0,totalOutputTokens:0,totalCacheCreateTokens:0,totalCacheReadTokens:0,todayCacheCreateTokens:0,todayCacheReadTokens:0,systemRPM:0,systemTPM:0,systemStatus:"正常",uptime:0,systemTimezone:8}),u=A({todayCosts:{totalCost:0,formatted:{totalCost:"$0.000000"}},totalCosts:{totalCost:0,formatted:{totalCost:"$0.000000"}}}),W=A([]),F=A([]),j=A([]),U=A({data:[],topApiKeys:[],totalApiKeys:0}),n=A({type:"preset",preset:"7days",customStart:"",customEnd:"",customRange:null,presetOptions:[{value:"today",label:"今日",days:1},{value:"7days",label:"7天",days:7},{value:"30days",label:"30天",days:30}]}),T=A("day"),O=A("requests"),K=A([new Date(2e3,1,1,0,0,0),new Date(2e3,2,1,23,59,59)]),st=yt(()=>{const a=B.value.uptime,r=Math.floor(a/86400),i=Math.floor(a%86400/3600),l=Math.floor(a%3600/60);return r>0?`${r}天 ${i}小时`:i>0?`${i}小时 ${l}分钟`:`${l}分钟`});function S(a,r=!0){const i=a.getFullYear(),l=a.getMonth(),s=a.getDate();return r?new Date(Date.UTC(i,l,s-1,16,0,0,0)):new Date(Date.UTC(i,l,s,15,59,59,999))}async function rt(){G.value=!0;try{const[a,r,i]=await Promise.all([N.get("/admin/dashboard"),N.get("/admin/usage-costs?period=today"),N.get("/admin/usage-costs?period=all")]);if(a.success){const l=a.data.overview||{},s=a.data.recentActivity||{},d=a.data.systemAverages||{},c=a.data.systemHealth||{};B.value={totalApiKeys:l.totalApiKeys||0,activeApiKeys:l.activeApiKeys||0,totalAccounts:l.totalClaudeAccounts||0,activeAccounts:l.activeClaudeAccounts||0,rateLimitedAccounts:l.rateLimitedClaudeAccounts||0,todayRequests:s.requestsToday||0,totalRequests:l.totalRequestsUsed||0,todayTokens:s.tokensToday||0,todayInputTokens:s.inputTokensToday||0,todayOutputTokens:s.outputTokensToday||0,totalTokens:l.totalTokensUsed||0,totalInputTokens:l.totalInputTokensUsed||0,totalOutputTokens:l.totalOutputTokensUsed||0,totalCacheCreateTokens:l.totalCacheCreateTokensUsed||0,totalCacheReadTokens:l.totalCacheReadTokensUsed||0,todayCacheCreateTokens:s.cacheCreateTokensToday||0,todayCacheReadTokens:s.cacheReadTokensToday||0,systemRPM:d.rpm||0,systemTPM:d.tpm||0,systemStatus:c.redisConnected?"正常":"异常",uptime:c.uptime||0,systemTimezone:a.data.systemTimezone||8}}r.success&&i.success&&(u.value={todayCosts:r.data.totalCosts||{totalCost:0,formatted:{totalCost:"$0.000000"}},totalCosts:i.data.totalCosts||{totalCost:0,formatted:{totalCost:"$0.000000"}}})}catch(a){console.error("加载仪表板数据失败:",a)}finally{G.value=!1}}async function at(a=7,r="day"){try{let i="/admin/usage-trend?";if(r==="hour")if(i+="granularity=hour",n.value.customRange&&n.value.customRange.length===2){const s=d=>{const[h,x]=d.split(" "),[k,p,e]=h.split("-").map(Number),[g,m,R]=x.split(":").map(Number);return new Date(Date.UTC(k,p-1,e,g-8,m,R)).toISOString()};i+=`&startDate=${encodeURIComponent(s(n.value.customRange[0]))}`,i+=`&endDate=${encodeURIComponent(s(n.value.customRange[1]))}`}else{const s=new Date;let d,c;if(n.value.type==="preset")switch(n.value.preset){case"last24h":c=new Date(s),d=new Date(s.getTime()-24*60*60*1e3);break;case"yesterday":const h=new Date;h.setDate(h.getDate()-1),d=S(h,!0),c=S(h,!1);break;case"dayBefore":const x=new Date;x.setDate(x.getDate()-2),d=S(x,!0),c=S(x,!1);break;default:d=new Date(s.getTime()-24*60*60*1e3),c=s}else d=new Date(s.getTime()-a*24*60*60*1e3),c=s;i+=`&startDate=${encodeURIComponent(d.toISOString())}`,i+=`&endDate=${encodeURIComponent(c.toISOString())}`}else i+=`granularity=day&days=${a}`;const l=await N.get(i);l.success&&(F.value=l.data)}catch(i){console.error("加载使用趋势失败:",i)}}async function Q(a="daily"){try{const r=await N.get(`/admin/model-stats?period=${a}`);r.success&&(j.value=r.data)}catch(r){console.error("加载模型统计失败:",r)}}async function Z(a="requests"){try{let r="/admin/api-keys-usage-trend?",i=7;if(T.value==="hour")if(r+="granularity=hour",n.value.customRange&&n.value.customRange.length===2){const s=d=>{const[h,x]=d.split(" "),[k,p,e]=h.split("-").map(Number),[g,m,R]=x.split(":").map(Number);return new Date(Date.UTC(k,p-1,e,g-8,m,R)).toISOString()};r+=`&startDate=${encodeURIComponent(s(n.value.customRange[0]))}`,r+=`&endDate=${encodeURIComponent(s(n.value.customRange[1]))}`}else{const s=new Date;let d,c;if(n.value.type==="preset")switch(n.value.preset){case"last24h":c=new Date(s),d=new Date(s.getTime()-24*60*60*1e3);break;case"yesterday":const h=new Date;h.setDate(h.getDate()-1),d=S(h,!0),c=S(h,!1);break;case"dayBefore":const x=new Date;x.setDate(x.getDate()-2),d=S(x,!0),c=S(x,!1);break;default:d=new Date(s.getTime()-24*60*60*1e3),c=s}else d=new Date(s.getTime()-24*60*60*1e3),c=s;r+=`&startDate=${encodeURIComponent(d.toISOString())}`,r+=`&endDate=${encodeURIComponent(c.toISOString())}`}else i=n.value.type==="preset"?n.value.preset==="today"?1:n.value.preset==="7days"?7:30:E(n.value.customStart,n.value.customEnd),r+=`granularity=day&days=${i}`;r+=`&metric=${a}`;const l=await N.get(r);l.success&&(U.value={data:l.data||[],topApiKeys:l.topApiKeys||[],totalApiKeys:l.totalApiKeys||0})}catch(r){console.error("加载API Keys趋势失败:",r)}}function z(a){n.value.type="preset",n.value.preset=a;const r=n.value.presetOptions.find(i=>i.value===a);if(r){const i=new Date;let l,s;if(T.value==="hour")switch(a){case"last24h":s=new Date(i),l=new Date(i.getTime()-24*60*60*1e3);break;case"yesterday":const d=new Date;d.setDate(d.getDate()-1),l=S(d,!0),s=S(d,!1);break;case"dayBefore":const c=new Date;c.setDate(c.getDate()-2),l=S(c,!0),s=S(c,!1);break}else l=new Date(i),s=new Date(i),a==="today"?(l.setHours(0,0,0,0),s.setHours(23,59,59,999)):(l.setDate(i.getDate()-(r.days-1)),l.setHours(0,0,0,0),s.setHours(23,59,59,999));if(n.value.customStart=l.toISOString().split("T")[0],n.value.customEnd=s.toISOString().split("T")[0],T.value==="hour"&&(a==="yesterday"||a==="dayBefore")){const d=new Date;a==="yesterday"?d.setDate(d.getDate()-1):d.setDate(d.getDate()-2);const c=d.getFullYear(),h=String(d.getMonth()+1).padStart(2,"0"),x=String(d.getDate()).padStart(2,"0");n.value.customRange=[`${c}-${h}-${x} 00:00:00`,`${c}-${h}-${x} 23:59:59`]}else{const d=c=>{const k=new Date(c.getTime()+288e5),p=k.getUTCFullYear(),e=String(k.getUTCMonth()+1).padStart(2,"0"),g=String(k.getUTCDate()).padStart(2,"0"),m=String(k.getUTCHours()).padStart(2,"0"),R=String(k.getUTCMinutes()).padStart(2,"0"),I=String(k.getUTCSeconds()).padStart(2,"0");return`${p}-${e}-${g} ${m}:${R}:${I}`};n.value.customRange=[d(l),d(s)]}}q()}function J(a){if(a&&a.length===2){n.value.type="custom",n.value.preset="",n.value.customRange=a,n.value.customStart=a[0].split(" ")[0],n.value.customEnd=a[1].split(" ")[0],B.value.systemTimezone;const r=s=>{const[d,c]=s.split(" "),[h,x,k]=d.split("-").map(Number),[p,e,g]=c.split(":").map(Number);return new Date(h,x-1,k,p,e,g)},i=r(a[0]),l=r(a[1]);if(T.value==="hour"){if((l-i)/36e5>24){nt("小时粒度下日期范围不能超过24小时","warning");return}}else if(Math.ceil((l-i)/864e5)+1>31){nt("日期范围不能超过 31 天","warning");return}q()}else a===null&&z(T.value==="hour"?"last24h":"7days")}function X(a){if(T.value=a,a==="hour"){if(n.value.presetOptions=[{value:"last24h",label:"近24小时",hours:24},{value:"yesterday",label:"昨天",hours:24},{value:"dayBefore",label:"前天",hours:24}],n.value.type==="custom"&&n.value.customRange&&n.value.customRange.length===2){const r=new Date(n.value.customRange[0]);if((new Date(n.value.customRange[1])-r)/(1e3*60*60)>24){nt("小时粒度下日期范围不能超过24小时,已切换到近24小时","warning"),z("last24h");return}}if(["today","7days","30days"].includes(n.value.preset)){z("last24h");return}}else if(n.value.presetOptions=[{value:"today",label:"今日",days:1},{value:"7days",label:"7天",days:7},{value:"30days",label:"30天",days:30}],["last24h","yesterday","dayBefore"].includes(n.value.preset)){z("7days");return}q()}async function q(){let a,r="monthly";if(n.value.type==="preset"){const i=n.value.presetOptions.find(l=>l.value===n.value.preset);T.value==="hour"?(a=1,r="daily"):(a=i?i.days:7,n.value.preset==="today"?r="daily":r="monthly")}else{if(T.value==="hour"){const i=new Date(n.value.customRange[0]),l=new Date(n.value.customRange[1]),s=Math.ceil((l-i)/(1e3*60*60));a=Math.ceil(s/24)||1}else a=E(n.value.customStart,n.value.customEnd);r="daily"}await Promise.all([at(a,T.value),Q(r),Z(O.value)])}function E(a,r){if(!a||!r)return 7;const i=new Date(a),l=new Date(r),s=Math.abs(l-i);return Math.ceil(s/(1e3*60*60*24))||7}function L(a){return a>new Date}return{loading:G,dashboardData:B,costsData:u,modelStats:W,trendData:F,dashboardModelStats:j,apiKeysTrendData:U,dateFilter:n,trendGranularity:T,apiKeysTrendMetric:O,defaultTime:K,formattedUptime:st,loadDashboardData:rt,loadUsageTrend:at,loadModelStats:Q,loadApiKeysTrend:Z,setDateFilterPreset:z,onCustomDateRangeChange:J,setTrendGranularity:X,refreshChartsData:q,disabledDate:L}}),vt={class:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-6 mb-8"},Tt={class:"stat-card"},kt={class:"flex items-center justify-between"},Ct={class:"text-3xl font-bold text-gray-900"},Dt={class:"text-xs text-gray-500 mt-1"},_t={class:"stat-card"},wt={class:"flex items-center justify-between"},St={class:"text-3xl font-bold text-gray-900"},Rt={class:"text-xs text-gray-500 mt-1"},$t={key:0,class:"text-yellow-600"},At={class:"stat-card"},Ut={class:"flex items-center justify-between"},Kt={class:"text-3xl font-bold text-gray-900"},Mt={class:"text-xs text-gray-500 mt-1"},It={class:"stat-card"},Pt={class:"flex items-center justify-between"},Ft={class:"text-3xl font-bold text-green-600"},Ot={class:"text-xs text-gray-500 mt-1"},Bt={class:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-6 mb-8"},zt={class:"stat-card"},qt={class:"flex items-center justify-between"},Et={class:"flex-1 mr-8"},Ht={class:"flex items-baseline gap-2 mb-2 flex-wrap"},Nt={class:"text-3xl font-bold text-blue-600"},jt={class:"text-sm text-green-600 font-medium"},Lt={class:"text-xs text-gray-500"},Yt={class:"flex justify-between items-center flex-wrap gap-x-4"},Vt={class:"font-medium"},Gt={class:"font-medium"},Wt={key:0,class:"text-purple-600"},Qt={class:"font-medium"},Zt={key:1,class:"text-purple-600"},Jt={class:"font-medium"},Xt={class:"stat-card"},te={class:"flex items-center justify-between"},ee={class:"flex-1 mr-8"},se={class:"flex items-baseline gap-2 mb-2 flex-wrap"},ae={class:"text-3xl font-bold text-emerald-600"},oe={class:"text-sm text-green-600 font-medium"},ne={class:"text-xs text-gray-500"},le={class:"flex justify-between items-center flex-wrap gap-x-4"},re={class:"font-medium"},ie={class:"font-medium"},de={key:0,class:"text-purple-600"},ue={class:"font-medium"},ce={key:1,class:"text-purple-600"},me={class:"font-medium"},pe={class:"stat-card"},ye={class:"flex items-center justify-between"},fe={class:"text-3xl font-bold text-orange-600"},ge={class:"stat-card"},xe={class:"flex items-center justify-between"},he={class:"text-3xl font-bold text-rose-600"},be={class:"mb-8"},ve={class:"flex items-center justify-between mb-6"},Te={class:"flex gap-2 items-center"},ke={class:"flex gap-1 bg-gray-100 rounded-lg p-1"},Ce=["onClick"],De={class:"flex gap-1 bg-gray-100 rounded-lg p-1"},_e={class:"flex items-center gap-2"},we={key:0,class:"text-xs text-orange-600"},Se={class:"grid grid-cols-1 lg:grid-cols-2 gap-6"},Re={class:"card p-6"},$e={class:"relative",style:{height:"300px"}},Ae={class:"card p-6"},Ue={key:0,class:"text-center py-8"},Ke={key:1,class:"overflow-auto max-h-[300px]"},Me={class:"min-w-full"},Ie={class:"divide-y divide-gray-200"},Pe={class:"px-4 py-2 text-sm text-gray-900"},Fe={class:"px-4 py-2 text-sm text-gray-600 text-right"},Oe={class:"px-4 py-2 text-sm text-gray-600 text-right"},Be={class:"px-4 py-2 text-sm text-green-600 text-right font-medium"},ze={class:"px-4 py-2 text-sm font-medium text-right"},qe={class:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800"},Ee={class:"mb-8"},He={class:"card p-6"},Ne={style:{height:"300px"}},je={class:"mb-8"},Le={class:"card p-6"},Ye={class:"flex items-center justify-between mb-4"},Ve={class:"flex gap-1 bg-gray-100 rounded-lg p-1"},Ge={class:"mb-4 text-sm text-gray-600"},We={key:0},Qe={key:1},Ze={style:{height:"350px"}},Je={__name:"DashboardView",setup(G){const B=bt(),{dashboardData:u,costsData:W,dashboardModelStats:F,trendData:j,apiKeysTrendData:U,formattedUptime:n,dateFilter:T,trendGranularity:O,apiKeysTrendMetric:K,defaultTime:st}=ft(B),{loadDashboardData:S,loadUsageTrend:rt,loadModelStats:at,loadApiKeysTrend:Q,setDateFilterPreset:Z,onCustomDateRangeChange:z,setTrendGranularity:J,refreshChartsData:X,disabledDate:q}=B,E=A(null),L=A(null),a=A(null);let r=null,i=null,l=null;function s(p){return p>=1e6?(p/1e6).toFixed(2)+"M":p>=1e3?(p/1e3).toFixed(2)+"K":p.toString()}function d(p,e){if(!e||e.length===0)return 0;const g=e.reduce((m,R)=>m+R.allTokens,0);return g===0?0:(p/g*100).toFixed(1)}function c(){if(!E.value)return;r&&r.destroy();const p=F.value||[],e={labels:p.map(g=>g.model),datasets:[{data:p.map(g=>g.allTokens),backgroundColor:["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#14B8A6","#F97316","#6366F1","#84CC16"],borderWidth:0}]};r=new lt(E.value,{type:"doughnut",data:e,options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"bottom",labels:{padding:15,usePointStyle:!0,font:{size:12}}},tooltip:{callbacks:{label:function(g){const m=g.label||"",R=s(g.parsed),I=d(g.parsed,p);return`${m}: ${R} (${I}%)`}}}}}})}function h(){var $;if(!L.value)return;i&&i.destroy();const p=j.value||[],e=p.map(f=>f.inputTokens||0),g=p.map(f=>f.outputTokens||0),m=p.map(f=>f.cacheCreateTokens||0),R=p.map(f=>f.cacheReadTokens||0),I=p.map(f=>f.requests||0),tt=p.map(f=>f.cost||0),et=($=p[0])!=null&&$.date?"date":"hour",M={labels:p.map(f=>{if(f.label)return f.label;if(et==="hour"){const v=new Date(f.hour),P=String(v.getMonth()+1).padStart(2,"0"),ut=String(v.getDate()).padStart(2,"0"),ct=String(v.getHours()).padStart(2,"0");return`${P}/${ut} ${ct}:00`}const C=f.date;if(C&&C.includes("-")){const v=C.split("-");if(v.length>=3)return`${v[1]}/${v[2]}`}return f.date}),datasets:[{label:"输入Token",data:e,borderColor:"rgb(102, 126, 234)",backgroundColor:"rgba(102, 126, 234, 0.1)",tension:.3},{label:"输出Token",data:g,borderColor:"rgb(240, 147, 251)",backgroundColor:"rgba(240, 147, 251, 0.1)",tension:.3},{label:"缓存创建Token",data:m,borderColor:"rgb(59, 130, 246)",backgroundColor:"rgba(59, 130, 246, 0.1)",tension:.3},{label:"缓存读取Token",data:R,borderColor:"rgb(147, 51, 234)",backgroundColor:"rgba(147, 51, 234, 0.1)",tension:.3},{label:"费用 (USD)",data:tt,borderColor:"rgb(34, 197, 94)",backgroundColor:"rgba(34, 197, 94, 0.1)",tension:.3,yAxisID:"y2"},{label:"请求数",data:I,borderColor:"rgb(16, 185, 129)",backgroundColor:"rgba(16, 185, 129, 0.1)",tension:.3,yAxisID:"y1"}]};i=new lt(L.value,{type:"line",data:M,options:{responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},plugins:{title:{display:!0,text:"Token使用趋势",font:{size:16,weight:"bold"}},legend:{position:"top"},tooltip:{mode:"index",intersect:!1,callbacks:{label:function(f){const C=f.dataset.label||"";let v=f.parsed.y;return C==="费用 (USD)"?v<.01?C+": $"+v.toFixed(6):C+": $"+v.toFixed(4):C==="请求数"?C+": "+v.toLocaleString()+" 次":C+": "+v.toLocaleString()+" tokens"}}}},scales:{x:{type:"category",display:!0,title:{display:!0,text:O.value==="hour"?"时间":"日期"}},y:{type:"linear",display:!0,position:"left",title:{display:!0,text:"Token数量"},ticks:{callback:function(f){return s(f)}}},y1:{type:"linear",display:!0,position:"right",title:{display:!0,text:"请求数"},grid:{drawOnChartArea:!1},ticks:{callback:function(f){return f.toLocaleString()}}},y2:{type:"linear",display:!1,position:"right"}}}})}function x(){var tt,et;if(!a.value)return;l&&l.destroy();const p=U.value.data||[],e=K.value,g=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#14B8A6","#F97316","#6366F1","#84CC16"],m=((tt=U.value.topApiKeys)==null?void 0:tt.map((b,M)=>{var C,v;const $=U.value.data.map(P=>!P.apiKeys||!P.apiKeys[b]?0:e==="tokens"?P.apiKeys[b].tokens:P.apiKeys[b].requests||0);return{label:((v=(C=U.value.data.find(P=>P.apiKeys&&P.apiKeys[b]))==null?void 0:C.apiKeys[b])==null?void 0:v.name)||`API Key ${b}`,data:$,borderColor:g[M%g.length],backgroundColor:g[M%g.length]+"20",tension:.4,fill:!1}}))||[],R=(et=p[0])!=null&&et.date?"date":"hour",I={labels:p.map(b=>{if(b.label)return b.label;if(R==="hour"){const $=new Date(b.hour),f=String($.getMonth()+1).padStart(2,"0"),C=String($.getDate()).padStart(2,"0"),v=String($.getHours()).padStart(2,"0");return`${f}/${C} ${v}:00`}const M=b.date;if(M&&M.includes("-")){const $=M.split("-");if($.length>=3)return`${$[1]}/${$[2]}`}return b.date}),datasets:m};l=new lt(a.value,{type:"line",data:I,options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"bottom",labels:{padding:20,usePointStyle:!0,font:{size:12}}},tooltip:{mode:"index",intersect:!1,callbacks:{label:function(b){const M=b.dataset.label||"",$=b.parsed.y,f=K.value==="tokens"?" tokens":" 次";return M+": "+$.toLocaleString()+f}}}},scales:{x:{type:"category",display:!0,title:{display:!0,text:O.value==="hour"?"时间":"日期"}},y:{beginAtZero:!0,title:{display:!0,text:K.value==="tokens"?"Token 数量":"请求次数"},ticks:{callback:function(b){return s(b)}}}}}})}async function k(){await Q(K.value),await Y(),x()}return ot(F,()=>{Y(()=>c())}),ot(j,()=>{Y(()=>h())}),ot(U,()=>{Y(()=>x())}),gt(async()=>{await Promise.all([S(),X()]),await Y(),c(),h(),x()}),(p,e)=>{const g=mt;return w(),D("div",null,[t("div",vt,[t("div",Tt,[t("div",kt,[t("div",null,[e[6]||(e[6]=t("p",{class:"text-sm font-semibold text-gray-600 mb-1"},"总API Keys",-1)),t("p",Ct,y(o(u).totalApiKeys),1),t("p",Dt,"活跃: "+y(o(u).activeApiKeys||0),1)]),e[7]||(e[7]=t("div",{class:"stat-icon flex-shrink-0 bg-gradient-to-br from-blue-500 to-blue-600"},[t("i",{class:"fas fa-key"})],-1))])]),t("div",_t,[t("div",wt,[t("div",null,[e[8]||(e[8]=t("p",{class:"text-sm font-semibold text-gray-600 mb-1"},"服务账户",-1)),t("p",St,y(o(u).totalAccounts),1),t("p",Rt,[_(" 活跃: "+y(o(u).activeAccounts||0)+" ",1),o(u).rateLimitedAccounts>0?(w(),D("span",$t," | 限流: "+y(o(u).rateLimitedAccounts),1)):H("",!0)])]),e[9]||(e[9]=t("div",{class:"stat-icon flex-shrink-0 bg-gradient-to-br from-green-500 to-green-600"},[t("i",{class:"fas fa-user-circle"})],-1))])]),t("div",At,[t("div",Ut,[t("div",null,[e[10]||(e[10]=t("p",{class:"text-sm font-semibold text-gray-600 mb-1"},"今日请求",-1)),t("p",Kt,y(o(u).todayRequests),1),t("p",Mt,"总请求: "+y(s(o(u).totalRequests||0)),1)]),e[11]||(e[11]=t("div",{class:"stat-icon flex-shrink-0 bg-gradient-to-br from-purple-500 to-purple-600"},[t("i",{class:"fas fa-chart-line"})],-1))])]),t("div",It,[t("div",Pt,[t("div",null,[e[12]||(e[12]=t("p",{class:"text-sm font-semibold text-gray-600 mb-1"},"系统状态",-1)),t("p",Ft,y(o(u).systemStatus),1),t("p",Ot,"运行时间: "+y(o(n)),1)]),e[13]||(e[13]=t("div",{class:"stat-icon flex-shrink-0 bg-gradient-to-br from-yellow-500 to-orange-500"},[t("i",{class:"fas fa-heartbeat"})],-1))])])]),t("div",Bt,[t("div",zt,[t("div",qt,[t("div",Et,[e[18]||(e[18]=t("p",{class:"text-sm font-semibold text-gray-600 mb-1"},"今日Token",-1)),t("div",Ht,[t("p",Nt,y(s((o(u).todayInputTokens||0)+(o(u).todayOutputTokens||0)+(o(u).todayCacheCreateTokens||0)+(o(u).todayCacheReadTokens||0))),1),t("span",jt,"/ "+y(o(W).todayCosts.formatted.totalCost),1)]),t("div",Lt,[t("div",Yt,[t("span",null,[e[14]||(e[14]=_("输入: ",-1)),t("span",Vt,y(s(o(u).todayInputTokens||0)),1)]),t("span",null,[e[15]||(e[15]=_("输出: ",-1)),t("span",Gt,y(s(o(u).todayOutputTokens||0)),1)]),(o(u).todayCacheCreateTokens||0)>0?(w(),D("span",Wt,[e[16]||(e[16]=_("缓存创建: ",-1)),t("span",Qt,y(s(o(u).todayCacheCreateTokens||0)),1)])):H("",!0),(o(u).todayCacheReadTokens||0)>0?(w(),D("span",Zt,[e[17]||(e[17]=_("缓存读取: ",-1)),t("span",Jt,y(s(o(u).todayCacheReadTokens||0)),1)])):H("",!0)])])]),e[19]||(e[19]=t("div",{class:"stat-icon flex-shrink-0 bg-gradient-to-br from-indigo-500 to-indigo-600"},[t("i",{class:"fas fa-coins"})],-1))])]),t("div",Xt,[t("div",te,[t("div",ee,[e[24]||(e[24]=t("p",{class:"text-sm font-semibold text-gray-600 mb-1"},"总Token消耗",-1)),t("div",se,[t("p",ae,y(s((o(u).totalInputTokens||0)+(o(u).totalOutputTokens||0)+(o(u).totalCacheCreateTokens||0)+(o(u).totalCacheReadTokens||0))),1),t("span",oe,"/ "+y(o(W).totalCosts.formatted.totalCost),1)]),t("div",ne,[t("div",le,[t("span",null,[e[20]||(e[20]=_("输入: ",-1)),t("span",re,y(s(o(u).totalInputTokens||0)),1)]),t("span",null,[e[21]||(e[21]=_("输出: ",-1)),t("span",ie,y(s(o(u).totalOutputTokens||0)),1)]),(o(u).totalCacheCreateTokens||0)>0?(w(),D("span",de,[e[22]||(e[22]=_("缓存创建: ",-1)),t("span",ue,y(s(o(u).totalCacheCreateTokens||0)),1)])):H("",!0),(o(u).totalCacheReadTokens||0)>0?(w(),D("span",ce,[e[23]||(e[23]=_("缓存读取: ",-1)),t("span",me,y(s(o(u).totalCacheReadTokens||0)),1)])):H("",!0)])])]),e[25]||(e[25]=t("div",{class:"stat-icon flex-shrink-0 bg-gradient-to-br from-emerald-500 to-emerald-600"},[t("i",{class:"fas fa-database"})],-1))])]),t("div",pe,[t("div",ye,[t("div",null,[e[26]||(e[26]=t("p",{class:"text-sm font-semibold text-gray-600 mb-1"},"平均RPM",-1)),t("p",fe,y(o(u).systemRPM||0),1),e[27]||(e[27]=t("p",{class:"text-xs text-gray-500 mt-1"},"每分钟请求数",-1))]),e[28]||(e[28]=t("div",{class:"stat-icon flex-shrink-0 bg-gradient-to-br from-orange-500 to-orange-600"},[t("i",{class:"fas fa-tachometer-alt"})],-1))])]),t("div",ge,[t("div",xe,[t("div",null,[e[29]||(e[29]=t("p",{class:"text-sm font-semibold text-gray-600 mb-1"},"平均TPM",-1)),t("p",he,y(o(u).systemTPM||0),1),e[30]||(e[30]=t("p",{class:"text-xs text-gray-500 mt-1"},"每分钟Token数",-1))]),e[31]||(e[31]=t("div",{class:"stat-icon flex-shrink-0 bg-gradient-to-br from-rose-500 to-rose-600"},[t("i",{class:"fas fa-rocket"})],-1))])])]),t("div",be,[t("div",ve,[e[36]||(e[36]=t("h3",{class:"text-xl font-bold text-gray-900"},"模型使用分布与Token使用趋势",-1)),t("div",Te,[t("div",ke,[(w(!0),D(it,null,dt(o(T).presetOptions,m=>(w(),D("button",{key:m.value,onClick:R=>o(Z)(m.value),class:V(["px-3 py-1 rounded-md text-sm font-medium transition-colors",o(T).preset===m.value&&o(T).type==="preset"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"])},y(m.label),11,Ce))),128))]),t("div",De,[t("button",{onClick:e[0]||(e[0]=m=>o(J)("day")),class:V(["px-3 py-1 rounded-md text-sm font-medium transition-colors",o(O)==="day"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"])},e[32]||(e[32]=[t("i",{class:"fas fa-calendar-day mr-1"},null,-1),_("按天 ",-1)]),2),t("button",{onClick:e[1]||(e[1]=m=>o(J)("hour")),class:V(["px-3 py-1 rounded-md text-sm font-medium transition-colors",o(O)==="hour"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"])},e[33]||(e[33]=[t("i",{class:"fas fa-clock mr-1"},null,-1),_("按小时 ",-1)]),2)]),t("div",_e,[xt(g,{"default-time":o(st),modelValue:o(T).customRange,"onUpdate:modelValue":e[2]||(e[2]=m=>o(T).customRange=m),type:"datetimerange","range-separator":"至","start-placeholder":"开始日期","end-placeholder":"结束日期",format:"YYYY-MM-DD HH:mm:ss","value-format":"YYYY-MM-DD HH:mm:ss",onChange:o(z),"disabled-date":o(q),size:"default",style:{width:"400px"},class:"custom-date-picker"},null,8,["default-time","modelValue","onChange","disabled-date"]),o(O)==="hour"?(w(),D("span",we,e[34]||(e[34]=[t("i",{class:"fas fa-info-circle"},null,-1),_(" 最多24小时 ",-1)]))):H("",!0)]),t("button",{onClick:e[3]||(e[3]=m=>o(X)()),class:"btn btn-primary px-4 py-2 flex items-center gap-2"},e[35]||(e[35]=[t("i",{class:"fas fa-sync-alt"},null,-1),_("刷新 ",-1)]))])]),t("div",Se,[t("div",Re,[e[37]||(e[37]=t("h4",{class:"text-lg font-semibold text-gray-800 mb-4"},"Token使用分布",-1)),t("div",$e,[t("canvas",{ref_key:"modelUsageChart",ref:E},null,512)])]),t("div",Ae,[e[40]||(e[40]=t("h4",{class:"text-lg font-semibold text-gray-800 mb-4"},"详细统计数据",-1)),o(F).length===0?(w(),D("div",Ue,e[38]||(e[38]=[t("p",{class:"text-gray-500"},"暂无模型使用数据",-1)]))):(w(),D("div",Ke,[t("table",Me,[e[39]||(e[39]=t("thead",{class:"bg-gray-50 sticky top-0"},[t("tr",null,[t("th",{class:"px-4 py-2 text-left text-xs font-medium text-gray-700"},"模型"),t("th",{class:"px-4 py-2 text-right text-xs font-medium text-gray-700"},"请求数"),t("th",{class:"px-4 py-2 text-right text-xs font-medium text-gray-700"},"总Token"),t("th",{class:"px-4 py-2 text-right text-xs font-medium text-gray-700"},"费用"),t("th",{class:"px-4 py-2 text-right text-xs font-medium text-gray-700"},"占比")])],-1)),t("tbody",Ie,[(w(!0),D(it,null,dt(o(F),m=>(w(),D("tr",{key:m.model,class:"hover:bg-gray-50"},[t("td",Pe,y(m.model),1),t("td",Fe,y(s(m.requests)),1),t("td",Oe,y(s(m.allTokens)),1),t("td",Be,y(m.formatted?m.formatted.total:"$0.000000"),1),t("td",ze,[t("span",qe,y(d(m.allTokens,o(F)))+"% ",1)])]))),128))])])]))])])]),t("div",Ee,[t("div",He,[t("div",Ne,[t("canvas",{ref_key:"usageTrendChart",ref:L},null,512)])])]),t("div",je,[t("div",Le,[t("div",Ye,[e[43]||(e[43]=t("h3",{class:"text-lg font-semibold text-gray-900"},"API Keys 使用趋势",-1)),t("div",Ve,[t("button",{onClick:e[4]||(e[4]=m=>{K.value="requests",k()}),class:V(["px-3 py-1 rounded-md text-sm font-medium transition-colors",o(K)==="requests"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"])},e[41]||(e[41]=[t("i",{class:"fas fa-exchange-alt mr-1"},null,-1),_("请求次数 ",-1)]),2),t("button",{onClick:e[5]||(e[5]=m=>{K.value="tokens",k()}),class:V(["px-3 py-1 rounded-md text-sm font-medium transition-colors",o(K)==="tokens"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"])},e[42]||(e[42]=[t("i",{class:"fas fa-coins mr-1"},null,-1),_("Token 数量 ",-1)]),2)])]),t("div",Ge,[o(U).totalApiKeys>10?(w(),D("span",We," 共 "+y(o(U).totalApiKeys)+" 个 API Key,显示使用量前 10 个 ",1)):(w(),D("span",Qe," 共 "+y(o(U).totalApiKeys)+" 个 API Key ",1))]),t("div",Ze,[t("canvas",{ref_key:"apiKeysUsageTrendChart",ref:a},null,512)])])])])}}},ns=ht(Je,[["__scopeId","data-v-d355f079"]]);export{ns as default};
|