diff --git a/webui/src/components/Log.vue b/webui/src/components/Log.vue index d4ce06c..e8260c0 100644 --- a/webui/src/components/Log.vue +++ b/webui/src/components/Log.vue @@ -40,6 +40,7 @@ interface LogEntry { const logs = ref([]) const logContainer = ref(null) const expanded = ref(true) +const lastTripRates = ref([]) const addLog = (level: LogEntry['level'], message: string) => { const now = new Date() @@ -47,6 +48,13 @@ const addLog = (level: LogEntry['level'], message: string) => { logs.value.push({ level, time, message }) + // 解析跳闸率数值 + const match = message.match(/不同相跳闸率是\[([\d.\s]+)\]/) + if (match) { + const values = match[1].trim().split(/\s+/).map(Number) + lastTripRates.value = values + } + // 自动滚动到底部 nextTick(() => { if (logContainer.value) { @@ -62,7 +70,8 @@ const clearLog = () => { // 暴露方法给父组件 defineExpose({ addLog, - clearLog + clearLog, + lastTripRates }) diff --git a/webui/src/components/ParameterForm.vue b/webui/src/components/ParameterForm.vue index 43664ca..82e98e8 100644 --- a/webui/src/components/ParameterForm.vue +++ b/webui/src/components/ParameterForm.vue @@ -381,17 +381,34 @@ const currentType = computed(() => { return params.parameter.rated_voltage.includes('±') ? 'DC' : 'AC' }) -// 当地闪密度大于 0 时,自动将雷暴日设为 -1,且不可编辑 -// 当地闪密度小于 0 时,自动将雷暴日设为 20,且可以编辑 -const isTdDisabled = computed(() => Number(params.advance.ng) > 0) +// 雷暴日与地闪密度相互转换,公式:ng = 0.023 * td^3 +// 标志位避免循环更新 +let isUpdatingFromWatch = false watch( () => params.advance.ng, (newNg) => { - if (Number(newNg) > 0) { - params.parameter.td = -1 - } else { - params.parameter.td = 20 + if (isUpdatingFromWatch) return + const ng = Number(newNg) + if (ng > 0) { + isUpdatingFromWatch = true + // td = (ng / 0.023)^(1/1.3) + params.parameter.td = Math.round(Math.pow(ng / 0.023, 1/1.3) * 100) / 100 + isUpdatingFromWatch = false + } + } +) + +watch( + () => params.parameter.td, + (newTd) => { + if (isUpdatingFromWatch) return + const td = Number(newTd) + if (td > 0) { + isUpdatingFromWatch = true + // ng = 0.023 * td^1.3 + params.advance.ng = Math.round(0.023 * Math.pow(td, 1.3) * 100) / 100 + isUpdatingFromWatch = false } } )