mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
feat: add rate limit recovery webhook notifications
添加限流恢复的 webhook 通知功能,当账户从限流状态自动恢复时发送通知。 主要改进: 1. **新增通知类型** (webhookConfigService.js) - 添加 `rateLimitRecovery` 通知类型 - 在配置获取和保存时自动合并默认通知类型 - 确保新增的通知类型有默认值 2. **增强限流清理服务** (rateLimitCleanupService.js) - 改进自动停止账户的检测逻辑 - 在 `finally` 块中确保 `clearedAccounts` 列表被重置,避免重复通知 - 对自动停止的账户显式调用 `removeAccountRateLimit` - 为 Claude 和 Claude Console 账户添加 `autoStopped` 和 `needsAutoStopRecovery` 检测 3. **改进 Claude Console 限流移除** (claudeConsoleAccountService.js) - 检测并恢复因自动停止而禁用调度的账户 - 清理过期的 `rateLimitAutoStopped` 标志 - 增加详细的日志记录 4. **前端 UI 支持** (SettingsView.vue) - 在 Webhook 设置中添加"限流恢复"通知类型选项 - 更新默认通知类型配置 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1255,15 +1255,18 @@ const testingConnection = ref(false)
|
||||
const savingPlatform = ref(false)
|
||||
|
||||
// Webhook 配置
|
||||
const DEFAULT_WEBHOOK_NOTIFICATION_TYPES = {
|
||||
accountAnomaly: true,
|
||||
quotaWarning: true,
|
||||
systemError: true,
|
||||
securityAlert: true,
|
||||
rateLimitRecovery: true
|
||||
}
|
||||
|
||||
const webhookConfig = ref({
|
||||
enabled: false,
|
||||
platforms: [],
|
||||
notificationTypes: {
|
||||
accountAnomaly: true,
|
||||
quotaWarning: true,
|
||||
systemError: true,
|
||||
securityAlert: true
|
||||
},
|
||||
notificationTypes: { ...DEFAULT_WEBHOOK_NOTIFICATION_TYPES },
|
||||
retrySettings: {
|
||||
maxRetries: 3,
|
||||
retryDelay: 1000,
|
||||
@@ -1475,7 +1478,14 @@ const loadWebhookConfig = async () => {
|
||||
signal: abortController.value.signal
|
||||
})
|
||||
if (response.success && isMounted.value) {
|
||||
webhookConfig.value = response.config
|
||||
const config = response.config || {}
|
||||
webhookConfig.value = {
|
||||
...config,
|
||||
notificationTypes: {
|
||||
...DEFAULT_WEBHOOK_NOTIFICATION_TYPES,
|
||||
...(config.notificationTypes || {})
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.name === 'AbortError') return
|
||||
@@ -1489,10 +1499,19 @@ const loadWebhookConfig = async () => {
|
||||
const saveWebhookConfig = async () => {
|
||||
if (!isMounted.value) return
|
||||
try {
|
||||
const response = await apiClient.post('/admin/webhook/config', webhookConfig.value, {
|
||||
const payload = {
|
||||
...webhookConfig.value,
|
||||
notificationTypes: {
|
||||
...DEFAULT_WEBHOOK_NOTIFICATION_TYPES,
|
||||
...(webhookConfig.value.notificationTypes || {})
|
||||
}
|
||||
}
|
||||
|
||||
const response = await apiClient.post('/admin/webhook/config', payload, {
|
||||
signal: abortController.value.signal
|
||||
})
|
||||
if (response.success && isMounted.value) {
|
||||
webhookConfig.value = payload
|
||||
showToast('配置已保存', 'success')
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -1930,6 +1949,7 @@ const getNotificationTypeName = (type) => {
|
||||
quotaWarning: '配额警告',
|
||||
systemError: '系统错误',
|
||||
securityAlert: '安全警报',
|
||||
rateLimitRecovery: '限流恢复',
|
||||
test: '测试通知'
|
||||
}
|
||||
return names[type] || type
|
||||
@@ -1941,6 +1961,7 @@ const getNotificationTypeDescription = (type) => {
|
||||
quotaWarning: 'API调用配额不足警告',
|
||||
systemError: '系统运行错误和故障',
|
||||
securityAlert: '安全相关的警报通知',
|
||||
rateLimitRecovery: '限流状态恢复时发送提醒',
|
||||
test: '用于测试Webhook连接是否正常'
|
||||
}
|
||||
return descriptions[type] || ''
|
||||
|
||||
Reference in New Issue
Block a user