From 5d7225b2eb8475489213868fc22470e3d1bed2f8 Mon Sep 17 00:00:00 2001 From: jft0m <377632523@qq.com> Date: Mon, 6 Oct 2025 15:34:13 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20Opus=20=E9=99=90?= =?UTF-8?q?=E6=B5=81=E7=8A=B6=E6=80=81=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在账户列表中显示 Opus 限流状态徽章 - 显示限流剩余时间(天/小时) - 后端 API 添加 opusRateLimitedAt 和 opusRateLimitEndAt 字段 - 优化徽章样式,防止文字溢出 --- src/services/claudeAccountService.js | 5 +- web/admin-spa/src/views/AccountsView.vue | 60 +++++++++++++++++++++++- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/services/claudeAccountService.js b/src/services/claudeAccountService.js index ec9e5b11..f931345e 100644 --- a/src/services/claudeAccountService.js +++ b/src/services/claudeAccountService.js @@ -528,7 +528,10 @@ class ClaudeAccountService { useUnifiedClientId: account.useUnifiedClientId === 'true', // 默认为false unifiedClientId: account.unifiedClientId || '', // 统一的客户端标识 // 添加停止原因 - stoppedReason: account.stoppedReason || null + stoppedReason: account.stoppedReason || null, + // 添加 Opus 限流信息 + opusRateLimitedAt: account.opusRateLimitedAt || null, + opusRateLimitEndAt: account.opusRateLimitEndAt || null } }) ) diff --git a/web/admin-spa/src/views/AccountsView.vue b/web/admin-spa/src/views/AccountsView.vue index f804f639..1a9469ee 100644 --- a/web/admin-spa/src/views/AccountsView.vue +++ b/web/admin-spa/src/views/AccountsView.vue @@ -606,9 +606,19 @@ >({{ formatRateLimitTime(account.rateLimitStatus.minutesRemaining) }}) + + + Opus限流 + + ({{ formatOpusLimitEndTime(account.opusRateLimitEndAt) }}) + + 不可调度 @@ -2491,6 +2501,54 @@ const formatRateLimitTime = (minutes) => { } } +// 检查账户是否处于 Opus 限流状态 +const isOpusRateLimited = (account) => { + if (!account.opusRateLimitEndAt) { + return false + } + const endTime = new Date(account.opusRateLimitEndAt) + const now = new Date() + return endTime > now +} + +// 格式化 Opus 限流结束时间 +const formatOpusLimitEndTime = (endTimeStr) => { + if (!endTimeStr) return '' + + const endTime = new Date(endTimeStr) + const now = new Date() + + // 如果已经过期,返回"已解除" + if (endTime <= now) { + return '已解除' + } + + // 计算剩余时间(毫秒) + const remainingMs = endTime - now + const remainingMinutes = Math.floor(remainingMs / (1000 * 60)) + + // 计算天数、小时和分钟 + const days = Math.floor(remainingMinutes / 1440) + const remainingAfterDays = remainingMinutes % 1440 + const hours = Math.floor(remainingAfterDays / 60) + const mins = remainingAfterDays % 60 + + // 格式化显示 + const parts = [] + if (days > 0) { + parts.push(`${days}天`) + } + if (hours > 0) { + parts.push(`${hours}小时`) + } + if (mins > 0 && days === 0) { + // 只有在天数为0时才显示分钟 + parts.push(`${mins}分钟`) + } + + return parts.join('') +} + // 打开创建账户模态框 const openCreateAccountModal = () => { newAccountPlatform.value = null // 重置选择的平台