feat(admin): 添加临时不可调度功能
当账号触发特定错误码和关键词匹配时,自动临时禁用调度: 后端: - 新增 TempUnschedCache Redis 缓存层 - RateLimitService 支持规则匹配和状态管理 - 添加 GET/DELETE /accounts/:id/temp-unschedulable API - 数据库迁移添加 temp_unschedulable_until/reason 字段 前端: - 账号状态指示器显示临时不可调度状态 - 新增 TempUnschedStatusModal 详情弹窗 - 创建/编辑账号时支持配置规则和预设模板 - 完整的中英文国际化支持
This commit is contained in:
@@ -12,7 +12,8 @@ import type {
|
||||
AccountUsageInfo,
|
||||
WindowStats,
|
||||
ClaudeModel,
|
||||
AccountUsageStatsResponse
|
||||
AccountUsageStatsResponse,
|
||||
TempUnschedulableStatus
|
||||
} from '@/types'
|
||||
|
||||
/**
|
||||
@@ -170,6 +171,30 @@ export async function clearRateLimit(id: number): Promise<{ message: string }> {
|
||||
return data
|
||||
}
|
||||
|
||||
/**
|
||||
* Get temporary unschedulable status
|
||||
* @param id - Account ID
|
||||
* @returns Status with detail state if active
|
||||
*/
|
||||
export async function getTempUnschedulableStatus(id: number): Promise<TempUnschedulableStatus> {
|
||||
const { data } = await apiClient.get<TempUnschedulableStatus>(
|
||||
`/admin/accounts/${id}/temp-unschedulable`
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset temporary unschedulable status
|
||||
* @param id - Account ID
|
||||
* @returns Success confirmation
|
||||
*/
|
||||
export async function resetTempUnschedulable(id: number): Promise<{ message: string }> {
|
||||
const { data } = await apiClient.delete<{ message: string }>(
|
||||
`/admin/accounts/${id}/temp-unschedulable`
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate OAuth authorization URL
|
||||
* @param endpoint - API endpoint path
|
||||
@@ -332,6 +357,8 @@ export const accountsAPI = {
|
||||
getUsage,
|
||||
getTodayStats,
|
||||
clearRateLimit,
|
||||
getTempUnschedulableStatus,
|
||||
resetTempUnschedulable,
|
||||
setSchedulable,
|
||||
getAvailableModels,
|
||||
generateAuthUrl,
|
||||
|
||||
Reference in New Issue
Block a user