fix: monitor-worker TypeScript 类型转换修复

This commit is contained in:
aiyimickey 2026-07-01 19:07:58 +08:00
parent 3504837405
commit d5956b6cfd
1 changed files with 8 additions and 7 deletions

View File

@ -141,20 +141,21 @@ export class MonitorWorker {
const results = await Promise.allSettled( const results = await Promise.allSettled(
channels.map(async (ch) => { channels.map(async (ch) => {
const raw = ch as unknown as Record<string, unknown>
const channel: AlertChannelConfig = { const channel: AlertChannelConfig = {
id: ch.id as number, id: ch.id as number,
name: ch.name as string, name: ch.name as string,
webhookUrl: (ch as Record<string, unknown>).webhook_url as string || '', webhookUrl: (raw.webhook_url as string) || '',
channelType: (ch as Record<string, unknown>).channel_type as string || 'wechat', channelType: (raw.channel_type as string) || 'wechat',
enabled: !!ch.enabled_num, enabled: !!ch.enabled_num,
levelCritical: !!ch.level_critical_num, levelCritical: !!ch.level_critical_num,
levelWarning: !!ch.level_warning_num, levelWarning: !!ch.level_warning_num,
levelInfo: !!ch.level_info_num, levelInfo: !!ch.level_info_num,
quietEnabled: !!(ch as Record<string, unknown>).quiet_enabled, quietEnabled: !!raw.quiet_enabled,
quietStart: (ch as Record<string, unknown>).quiet_start as string || '23:00', quietStart: (raw.quiet_start as string) || '23:00',
quietEnd: (ch as Record<string, unknown>).quiet_end as string || '07:00', quietEnd: (raw.quiet_end as string) || '07:00',
quietBypassCritical: !!(ch as Record<string, unknown>).quiet_bypass_critical, quietBypassCritical: !!raw.quiet_bypass_critical,
cooldownMinutes: Number((ch as Record<string, unknown>).cooldown_minutes) || 5, cooldownMinutes: Number(raw.cooldown_minutes) || 5,
} }
const decision = await this.alertManager.evaluate(channel, svc.id, level) const decision = await this.alertManager.evaluate(channel, svc.id, level)
if (decision.shouldPush) { if (decision.shouldPush) {