update烟气

This commit is contained in:
lb
2023-12-28 16:16:31 +08:00
parent 4e73410495
commit 049a0804ac
6 changed files with 340 additions and 192 deletions

21
src/utils/smoke.ts Normal file
View File

@@ -0,0 +1,21 @@
import { store } from "../store";
export default function handler(msg: MessageEvent) {
let serializedData: { type: string; data: any } | null = null;
try {
serializedData = JSON.parse(msg.data);
} catch (error) {
console.log("[*] websocket: [unable to serialize] ---> ", msg);
}
switch (serializedData?.type) {
case "exhaustGas": {
store.dispatch("smoke/setInfo", serializedData.data.realtime);
store.dispatch("smoke/setTrend", serializedData.data);
break;
}
default: {
console.log("websocket message: [unknown] ---> ", msg.data);
}
}
}