From b34da837e219c3f79d7f39847e2bbd4f80f8253e Mon Sep 17 00:00:00 2001 From: dmy Date: Tue, 3 Mar 2026 15:07:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=B1=95=E7=A4=BA=E5=B9=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=A4=E7=9B=B4=E6=B5=81=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在参数表单中重新排列计算结果和日志组件的位置,将跳闸率显示格式化为4位小数并添加单位。同时在后端日志中添加交直流标识输出,并自动根据电压等级更新ac_or_dc字段。 --- main.py | 1 + webui/src/components/ParameterForm.vue | 32 ++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index d400f30..528f882 100644 --- a/main.py +++ b/main.py @@ -152,6 +152,7 @@ def run_egm(para: Parameter) -> dict: logger.info(f"挂点处保护角{shield_angle_at_avg_height:.3f}°") logger.debug(f"最低相防护标识{rg_type}。(g表示地面,c表示下导线)") rated_voltage = para.rated_voltage + logger.info(f"交、直流标识{para.ac_or_dc}") for u_bar in range(voltage_n): # 计算不同工作电压下的跳闸率 if para.ac_or_dc=="AC": # TODO 需要区分交、直流 diff --git a/webui/src/components/ParameterForm.vue b/webui/src/components/ParameterForm.vue index c769f2b..e98b6e7 100644 --- a/webui/src/components/ParameterForm.vue +++ b/webui/src/components/ParameterForm.vue @@ -318,10 +318,7 @@ - - - - +
@@ -330,8 +327,8 @@
-
-
跳闸率:{{ result.tripping_rate }}
+
+
跳闸率:{{ result.tripping_rate.toFixed(4) }} 次/(100km·a)
各导线跳闸率: @@ -342,6 +339,10 @@
+ + + +
@@ -382,7 +383,7 @@ const defaultParams: AllParameters = { const params = reactive(JSON.parse(JSON.stringify(defaultParams))) const calculating = ref(false) -const result = ref<{ tripping_rate: string; n_sf_phases: number[]; message: string } | null>(null) +const result = ref<{ tripping_rate: number; n_sf_phases: number[]; message: string } | null>(null) const error = ref(null) const logRef = ref | null>(null) const fileInput = ref(null) @@ -397,6 +398,15 @@ const currentType = computed(() => { return params.parameter.rated_voltage.includes('±') ? 'DC' : 'AC' }) +// 监听电压等级变化,同步更新 ac_or_dc 字段 +watch( + () => params.parameter.rated_voltage, + (newVoltage) => { + params.parameter.ac_or_dc = newVoltage.includes('±') ? 'DC' : 'AC' + }, + { immediate: true } +) + // 雷暴日与地闪密度相互转换,公式:ng = 0.023 * td^3 // 标志位避免循环更新 let isUpdatingFromWatch = false @@ -495,7 +505,7 @@ const calculate = async () => { logRef.value?.addLog('info', '参数: 额定电压=750kV, 雷暴日=20d, 海拔=1000m') logRef.value?.addLog('info', '计算完成') result.value = { - tripping_rate: '0.0581 次/(100km·a)', + tripping_rate: 0.0581, n_sf_phases: [0.0421, 0.0581, 0.0392], message: '计算完成' } @@ -731,7 +741,7 @@ onMounted(() => { calculating.value = false if (res.success && res.data) { result.value = { - tripping_rate: res.data.tripping_rate || '', + tripping_rate: res.data.avr_n_sf || 0, n_sf_phases: res.data.n_sf_phases || [], message: res.message || '计算完成' } @@ -749,4 +759,8 @@ onUnmounted(() => { \ No newline at end of file