mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
2 lines
4.7 KiB
JavaScript
2 lines
4.7 KiB
JavaScript
import{r as P,c as y,o as L,q as R,V as B,x as r,y as o,z as n,L as c,P as l,O as g,B as w,C as v}from"./vue-vendor-R8HMg95E.js";const E={class:"space-y-1"},I={class:"flex items-center justify-between text-xs"},j={class:"text-gray-500"},F={key:0,class:"font-medium text-gray-700"},V={key:1,class:"font-medium text-orange-600"},z={key:2,class:"font-medium text-gray-500"},D={key:3,class:"font-medium text-gray-400"},W={key:0,class:"space-y-0.5"},K={key:0,class:"space-y-0.5"},O={class:"flex items-center justify-between text-xs"},U={class:"text-gray-600"},A={class:"h-1 w-full rounded-full bg-gray-200"},G={key:1,class:"space-y-0.5"},H={class:"flex items-center justify-between text-xs"},J={class:"text-gray-600"},Q={class:"h-1 w-full rounded-full bg-gray-200"},X={key:2,class:"space-y-0.5"},Y={class:"flex items-center justify-between text-xs"},Z={class:"text-gray-600"},ee={class:"h-1 w-full rounded-full bg-gray-200"},te={key:1,class:"text-xs text-gray-500"},se={key:0},ne={key:1},re={key:2},ie={__name:"WindowCountdown",props:{label:{type:String,default:"窗口限制"},rateLimitWindow:{type:Number,required:!0},windowStartTime:{type:Number,default:null},windowEndTime:{type:Number,default:null},windowRemainingSeconds:{type:Number,default:null},currentRequests:{type:Number,default:0},requestLimit:{type:Number,default:0},currentTokens:{type:Number,default:0},tokenLimit:{type:Number,default:0},currentCost:{type:Number,default:0},costLimit:{type:Number,default:0},showProgress:{type:Boolean,default:!0},showTooltip:{type:Boolean,default:!1}},setup(a){const s=a,i=P(s.windowRemainingSeconds);let u=null;const m=y(()=>s.windowStartTime===null?"notStarted":i.value===0?"expired":i.value>0?"active":"unknown"),_=y(()=>s.requestLimit>0),T=y(()=>s.tokenLimit>0),C=y(()=>s.costLimit>0),q=e=>{if(e==null)return"--:--";const t=Math.floor(e/3600),d=Math.floor(e%3600/60),k=e%60;return t>0?`${t}h ${d}m`:d>0?`${d}m ${k}s`:`${k}s`},N=e=>{const t=Math.floor(e/3600),d=Math.floor(e%3600/60);return t>0?`${t}小时${d}分钟`:`${d}分钟`},h=e=>e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"K":e.toString(),x=()=>{if(!s.requestLimit||s.requestLimit===0)return 0;const e=(s.currentRequests||0)/s.requestLimit*100;return Math.min(e,100)},S=()=>{const e=x();return e>=100?"bg-red-500":e>=80?"bg-yellow-500":"bg-blue-500"},p=()=>{if(!s.tokenLimit||s.tokenLimit===0)return 0;const e=(s.currentTokens||0)/s.tokenLimit*100;return Math.min(e,100)},M=()=>{const e=p();return e>=100?"bg-red-500":e>=80?"bg-yellow-500":"bg-purple-500"},b=()=>{if(!s.costLimit||s.costLimit===0)return 0;const e=(s.currentCost||0)/s.costLimit*100;return Math.min(e,100)},$=()=>{const e=b();return e>=100?"bg-red-500":e>=80?"bg-yellow-500":"bg-green-500"},f=()=>{if(s.windowEndTime&&i.value>0){const e=Date.now(),t=Math.max(0,Math.floor((s.windowEndTime-e)/1e3));i.value=t,t===0&&u&&(clearInterval(u),u=null)}};return L(()=>s.windowRemainingSeconds,e=>{i.value=e}),L(()=>s.windowEndTime,e=>{e&&(f(),!u&&i.value>0&&(u=setInterval(f,1e3)))}),R(()=>{s.windowEndTime&&i.value>0&&(f(),u=setInterval(f,1e3))}),B(()=>{u&&clearInterval(u)}),(e,t)=>(o(),r("div",E,[n("div",I,[n("span",j,l(a.label),1),m.value==="active"?(o(),r("span",F,[t[0]||(t[0]=n("i",{class:"fas fa-clock mr-1 text-blue-500"},null,-1)),g(" "+l(q(i.value)),1)])):m.value==="expired"?(o(),r("span",V,t[1]||(t[1]=[n("i",{class:"fas fa-sync-alt mr-1"},null,-1),g(" 窗口已过期 ",-1)]))):m.value==="notStarted"?(o(),r("span",z,t[2]||(t[2]=[n("i",{class:"fas fa-pause-circle mr-1"},null,-1),g(" 窗口未激活 ",-1)]))):(o(),r("span",D,l(a.rateLimitWindow)+" 分钟 ",1))]),a.showProgress?(o(),r("div",W,[_.value?(o(),r("div",K,[n("div",O,[t[3]||(t[3]=n("span",{class:"text-gray-400"},"请求",-1)),n("span",U,l(a.currentRequests||0)+"/"+l(a.requestLimit),1)]),n("div",A,[n("div",{class:v(["h-1 rounded-full transition-all duration-300",S()]),style:w({width:x()+"%"})},null,6)])])):c("",!0),T.value?(o(),r("div",G,[n("div",H,[t[4]||(t[4]=n("span",{class:"text-gray-400"},"Token",-1)),n("span",J,l(h(a.currentTokens||0))+"/"+l(h(a.tokenLimit)),1)]),n("div",Q,[n("div",{class:v(["h-1 rounded-full transition-all duration-300",M()]),style:w({width:p()+"%"})},null,6)])])):c("",!0),C.value?(o(),r("div",X,[n("div",Y,[t[5]||(t[5]=n("span",{class:"text-gray-400"},"费用",-1)),n("span",Z," $"+l((a.currentCost||0).toFixed(2))+"/$"+l(a.costLimit.toFixed(2)),1)]),n("div",ee,[n("div",{class:v(["h-1 rounded-full transition-all duration-300",$()]),style:w({width:b()+"%"})},null,6)])])):c("",!0)])):c("",!0),m.value==="active"&&a.showTooltip?(o(),r("div",te,[t[6]||(t[6]=n("i",{class:"fas fa-info-circle mr-1"},null,-1)),i.value<60?(o(),r("span",se,"即将重置")):i.value<300?(o(),r("span",ne,l(Math.ceil(i.value/60))+" 分钟后重置",1)):(o(),r("span",re,l(N(i.value))+"后重置",1))])):c("",!0)]))}};export{ie as _};
|