feat(admin): 添加临时不可调度功能

当账号触发特定错误码和关键词匹配时,自动临时禁用调度:

后端:
- 新增 TempUnschedCache Redis 缓存层
- RateLimitService 支持规则匹配和状态管理
- 添加 GET/DELETE /accounts/:id/temp-unschedulable API
- 数据库迁移添加 temp_unschedulable_until/reason 字段

前端:
- 账号状态指示器显示临时不可调度状态
- 新增 TempUnschedStatusModal 详情弹窗
- 创建/编辑账号时支持配置规则和预设模板
- 完整的中英文国际化支持
This commit is contained in:
ianshaw
2026-01-03 06:34:00 -08:00
parent acb718d355
commit 09da6904f5
18 changed files with 1829 additions and 199 deletions

View File

@@ -330,6 +330,27 @@ export interface GeminiCredentials {
expires_at?: string
}
export interface TempUnschedulableRule {
error_code: number
keywords: string[]
duration_minutes: number
description: string
}
export interface TempUnschedulableState {
until_unix: number
triggered_at_unix: number
status_code: number
matched_keyword: string
rule_index: number
error_message: string
}
export interface TempUnschedulableStatus {
active: boolean
state?: TempUnschedulableState
}
export interface Account {
id: number
name: string
@@ -355,6 +376,8 @@ export interface Account {
rate_limited_at: string | null
rate_limit_reset_at: string | null
overload_until: string | null
temp_unschedulable_until: string | null
temp_unschedulable_reason: string | null
// Session window fields (5-hour window)
session_window_start: string | null
@@ -376,6 +399,12 @@ export interface UsageProgress {
window_stats?: WindowStats | null // 窗口期统计(从窗口开始到当前的使用量)
}
// Antigravity 单个模型的配额信息
export interface AntigravityModelQuota {
utilization: number // 使用率 0-100
reset_time: string // 重置时间 ISO8601
}
export interface AccountUsageInfo {
updated_at: string | null
five_hour: UsageProgress | null
@@ -383,6 +412,7 @@ export interface AccountUsageInfo {
seven_day_sonnet: UsageProgress | null
gemini_pro_daily?: UsageProgress | null
gemini_flash_daily?: UsageProgress | null
antigravity_quota?: Record<string, AntigravityModelQuota> | null
}
// OpenAI Codex usage snapshot (from response headers)
@@ -418,6 +448,7 @@ export interface CreateAccountRequest {
concurrency?: number
priority?: number
group_ids?: number[]
confirm_mixed_channel_risk?: boolean
}
export interface UpdateAccountRequest {
@@ -430,6 +461,7 @@ export interface UpdateAccountRequest {
priority?: number
status?: 'active' | 'inactive'
group_ids?: number[]
confirm_mixed_channel_risk?: boolean
}
export interface CreateProxyRequest {
@@ -619,7 +651,7 @@ export interface UserUsageTrendPoint {
actual_cost: number // 实际扣除
}
export interface APIKeyUsageTrendPoint {
export interface ApiKeyUsageTrendPoint {
date: string
api_key_id: number
key_name: string