mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 09:38:02 +00:00
fix: 修复apikey窗口限制时间显示异常的问题
This commit is contained in:
@@ -620,6 +620,8 @@ async function calculateKeyStats(keyId, timeRange, startDate, endDate) {
|
|||||||
let dailyCost = 0
|
let dailyCost = 0
|
||||||
let currentWindowCost = 0
|
let currentWindowCost = 0
|
||||||
let windowRemainingSeconds = null
|
let windowRemainingSeconds = null
|
||||||
|
let windowStartTime = null
|
||||||
|
let windowEndTime = null
|
||||||
let allTimeCost = 0
|
let allTimeCost = 0
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -642,9 +644,9 @@ async function calculateKeyStats(keyId, timeRange, startDate, endDate) {
|
|||||||
const windowStart = await client.get(windowStartKey)
|
const windowStart = await client.get(windowStartKey)
|
||||||
if (windowStart) {
|
if (windowStart) {
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
const windowStartTime = parseInt(windowStart)
|
windowStartTime = parseInt(windowStart)
|
||||||
const windowDuration = apiKey.rateLimitWindow * 60 * 1000 // 转换为毫秒
|
const windowDuration = apiKey.rateLimitWindow * 60 * 1000 // 转换为毫秒
|
||||||
const windowEndTime = windowStartTime + windowDuration
|
windowEndTime = windowStartTime + windowDuration
|
||||||
|
|
||||||
// 如果窗口还有效
|
// 如果窗口还有效
|
||||||
if (now < windowEndTime) {
|
if (now < windowEndTime) {
|
||||||
@@ -673,6 +675,8 @@ async function calculateKeyStats(keyId, timeRange, startDate, endDate) {
|
|||||||
dailyCost,
|
dailyCost,
|
||||||
currentWindowCost,
|
currentWindowCost,
|
||||||
windowRemainingSeconds,
|
windowRemainingSeconds,
|
||||||
|
windowStartTime,
|
||||||
|
windowEndTime,
|
||||||
allTimeCost // 历史总费用(用于总费用限制)
|
allTimeCost // 历史总费用(用于总费用限制)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3969,6 +3969,8 @@ const showUsageDetails = (apiKey) => {
|
|||||||
dailyCost: cachedStats?.dailyCost ?? apiKey.dailyCost ?? 0,
|
dailyCost: cachedStats?.dailyCost ?? apiKey.dailyCost ?? 0,
|
||||||
currentWindowCost: cachedStats?.currentWindowCost ?? apiKey.currentWindowCost ?? 0,
|
currentWindowCost: cachedStats?.currentWindowCost ?? apiKey.currentWindowCost ?? 0,
|
||||||
windowRemainingSeconds: cachedStats?.windowRemainingSeconds ?? apiKey.windowRemainingSeconds,
|
windowRemainingSeconds: cachedStats?.windowRemainingSeconds ?? apiKey.windowRemainingSeconds,
|
||||||
|
windowStartTime: cachedStats?.windowStartTime ?? apiKey.windowStartTime ?? null,
|
||||||
|
windowEndTime: cachedStats?.windowEndTime ?? apiKey.windowEndTime ?? null,
|
||||||
// 合并 usage 数据(用于详情弹窗中的统计卡片)
|
// 合并 usage 数据(用于详情弹窗中的统计卡片)
|
||||||
usage: {
|
usage: {
|
||||||
...apiKey.usage,
|
...apiKey.usage,
|
||||||
|
|||||||
Reference in New Issue
Block a user