Browse Source

perf(views): 优化“监测点”控件异常判断逻辑

wangcong 2 months ago
parent
commit
be8c41affb
1 changed files with 28 additions and 2 deletions
  1. 28 2
      src/views/EnvArea/pens/monitorPoint.ts

+ 28 - 2
src/views/EnvArea/pens/monitorPoint.ts

@@ -1,9 +1,35 @@
 import { EventAction, getFont, Pen } from "@meta2d/core";
 import { MonitoringPointData } from "@/types";
 
+const enum MonitorPointStatus {
+  /**
+   * 离线
+   */
+  Offline = -1,
+  /**
+   * 关闭
+   */
+  Closed = 0,
+  /**
+   * 正常
+   */
+  Normal = 1,
+  /**
+   * 预警
+   */
+  Warning = 2,
+  /**
+   * 超标
+   */
+  Exceed = 3,
+}
+
 const isPointNormal = (point: MonitoringPointData) => {
-  const { temperature, humidity } = point;
-  return temperature !== null && humidity !== null;
+  const { status } = point;
+  return (
+    status !== MonitorPointStatus.Warning &&
+    status !== MonitorPointStatus.Exceed
+  );
 };
 
 export interface MonitorPointPen extends Pen {