Compare commits

..

2 Commits

Author SHA1 Message Date
github-actions[bot]
0035f8cb4f chore: sync VERSION file with release v1.1.226 [skip ci] 2025-12-08 01:45:46 +00:00
shaw
d49cc0cec8 fix: 修复api-keys页面窗口费率显示问题 2025-12-08 09:45:19 +08:00
2 changed files with 7 additions and 4 deletions

View File

@@ -1 +1 @@
1.1.225
1.1.226

View File

@@ -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 {