51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
import { store } from "../store";
|
|
|
|
export default function handler(msg) {
|
|
let serializedData = null;
|
|
try {
|
|
serializedData = JSON.parse(msg.data);
|
|
} catch (error) {
|
|
console.log("[*] websocket: [unable to serialize] ---> ", msg);
|
|
}
|
|
|
|
console.log("[ISRA DATA] ---> ", serializedData);
|
|
|
|
if (serializedData == null || serializedData.detData == null) return;
|
|
|
|
const { detData } = serializedData;
|
|
// 处理 checkTypeList
|
|
store.dispatch({
|
|
type: "isra/setCheckType",
|
|
payload: detData.checkType,
|
|
});
|
|
// for (const checkType of serializedData.checkTypeList) {
|
|
// store.dispatch({
|
|
// type: 'isra/setCheckTypeList',
|
|
// payload: serializedData.checkTypeList
|
|
// })
|
|
// }
|
|
|
|
// 处理 dayStatistic 等数据
|
|
if ("dayStatistic" in detData) {
|
|
store.dispatch({
|
|
type: "isra/setDayStatistic",
|
|
payload: detData.dayStatistic,
|
|
});
|
|
} else if ("weekStatistic" in detData) {
|
|
store.dispatch({
|
|
type: "isra/setWeekStatistic",
|
|
payload: serializedData.detData,
|
|
});
|
|
} else if ("monthStatistic" in detData) {
|
|
store.dispatch({
|
|
type: "isra/setMonthStatistic",
|
|
payload: detData.monthStatistic,
|
|
});
|
|
} else if ("yearStatistic" in detData) {
|
|
store.dispatch({
|
|
type: "isra/setYearStatistic",
|
|
payload: detData.yearStatistic,
|
|
});
|
|
}
|
|
}
|