Просмотр исходного кода

更新TopoDetail组件中的告警触发逻辑,确保数值比较时将字符串转换为数字;在App.jsx中修改TopoDetailModal的id属性。

valentichu 7 месяцев назад
Родитель
Сommit
15e5b9e01f
3 измененных файлов с 11 добавлено и 6 удалено
  1. 0 0
      lib/index.js
  2. 1 1
      src/App.jsx
  3. 10 5
      src/pages/Alarm/components/topoDetail.jsx

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
lib/index.js


+ 1 - 1
src/App.jsx

@@ -60,7 +60,7 @@ function Home(props) {
         ></Alarm.EasyConfig>
       </div> */}
       <Alarm.TopoDetailModal
-        id={690332}
+        id={690384}
         alarmTime="2025-06-17 00:00:00"
         open={true}
         onCancel={() => {}}

+ 10 - 5
src/pages/Alarm/components/topoDetail.jsx

@@ -287,17 +287,22 @@ const TopoDetail = (props) => {
 
   // 根据compare_type判断是否触发告警
   const isAlarmTriggered = (value, threshold, compareType) => {
+    // 确保数值比较,转换为数字
+    const numValue = typeof value === "string" ? parseFloat(value) : value;
+    const numThreshold =
+      typeof threshold === "string" ? parseFloat(threshold) : threshold;
+
     switch (compareType) {
       case 1: // >=
-        return value >= threshold;
+        return numValue >= numThreshold;
       case 2: // <=
-        return value <= threshold;
+        return numValue <= numThreshold;
       case 3: // <
-        return value < threshold;
+        return numValue < numThreshold;
       case 4: // >
-        return value > threshold;
+        return numValue > numThreshold;
       case 5: // ==
-        return value === threshold;
+        return numValue === numThreshold;
       default:
         return false;
     }

Некоторые файлы не были показаны из-за большого количества измененных файлов