mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
fix: 修复api-keys页面窗口费率显示问题
This commit is contained in:
@@ -1047,7 +1047,10 @@ async function calculateKeyStats(keyId, timeRange, startDate, endDate) {
|
||||
|
||||
// 获取 API Key 配置信息以判断是否需要窗口数据
|
||||
const apiKey = await redis.getApiKey(keyId)
|
||||
if (apiKey && apiKey.rateLimitWindow > 0) {
|
||||
// 显式转换为整数,与 apiStats.js 保持一致,避免字符串比较问题
|
||||
const rateLimitWindow = parseInt(apiKey?.rateLimitWindow) || 0
|
||||
|
||||
if (rateLimitWindow > 0) {
|
||||
const costCountKey = `rate_limit:cost:${keyId}`
|
||||
const windowStartKey = `rate_limit:window_start:${keyId}`
|
||||
|
||||
@@ -1058,7 +1061,7 @@ async function calculateKeyStats(keyId, timeRange, startDate, endDate) {
|
||||
if (windowStart) {
|
||||
const now = Date.now()
|
||||
windowStartTime = parseInt(windowStart)
|
||||
const windowDuration = apiKey.rateLimitWindow * 60 * 1000 // 转换为毫秒
|
||||
const windowDuration = rateLimitWindow * 60 * 1000 // 转换为毫秒
|
||||
windowEndTime = windowStartTime + windowDuration
|
||||
|
||||
// 如果窗口还有效
|
||||
@@ -1072,7 +1075,7 @@ async function calculateKeyStats(keyId, timeRange, startDate, endDate) {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
logger.debug(`获取实时限制数据失败 (key: ${keyId}):`, error.message)
|
||||
logger.warn(`⚠️ 获取实时限制数据失败 (key: ${keyId}):`, error.message)
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user