소스 검색

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

wangcong 2 달 전
부모
커밋
be8c41affb
1개의 변경된 파일28개의 추가작업 그리고 2개의 파일을 삭제
  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 {