refactor(ops): 简化自动刷新定时器逻辑
- 合并双定时器为单一倒计时定时器 - 倒计时归零时触发数据刷新 - 添加自定义时间范围的安全回退
This commit is contained in:
@@ -191,8 +191,10 @@ function handleCustomTimeRangeConfirm() {
|
||||
if (!customStartTimeInput.value || !customEndTimeInput.value) return
|
||||
const startTime = new Date(customStartTimeInput.value).toISOString()
|
||||
const endTime = new Date(customEndTimeInput.value).toISOString()
|
||||
emit('update:timeRange', 'custom')
|
||||
// Emit custom time range first so the parent can build correct API params
|
||||
// when it reacts to timeRange switching to "custom".
|
||||
emit('update:customTimeRange', startTime, endTime)
|
||||
emit('update:timeRange', 'custom')
|
||||
showCustomTimeRangeDialog.value = false
|
||||
}
|
||||
|
||||
@@ -221,8 +223,14 @@ function getSLAThresholdLevel(slaPercent: number | null): ThresholdLevel {
|
||||
if (slaPercent == null) return 'normal'
|
||||
const threshold = props.thresholds?.sla_percent_min
|
||||
if (threshold == null) return 'normal'
|
||||
|
||||
// SLA is "higher is better":
|
||||
// - below threshold => critical
|
||||
// - within +0.1% buffer => warning
|
||||
const warningBuffer = 0.1
|
||||
|
||||
if (slaPercent < threshold) return 'critical'
|
||||
if (slaPercent < threshold / 0.8) return 'warning'
|
||||
if (slaPercent < threshold + warningBuffer) return 'warning'
|
||||
return 'normal'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user