perf: reduce ref update times
This commit is contained in:
@@ -62,7 +62,8 @@ export function useLineAlarmsQuery() {
|
||||
if (!lineAlarms.value[station.code]) {
|
||||
lineAlarms.value[station.code] = createEmptyStationAlarms();
|
||||
}
|
||||
const stationAlarms = lineAlarms.value[station.code];
|
||||
// const stationAlarms = lineAlarms.value[station.code];
|
||||
const stationAlarms = createEmptyStationAlarms();
|
||||
|
||||
try {
|
||||
const now = dayjs();
|
||||
@@ -100,6 +101,8 @@ export function useLineAlarmsQuery() {
|
||||
const videoServerAlarms = alarmList.filter((device) => device.deviceType === DeviceType.VideoServer);
|
||||
stationAlarms[DeviceType.VideoServer] = videoServerAlarms;
|
||||
stationAlarms.unclassified = alarmList;
|
||||
|
||||
lineAlarms.value[station.code] = stationAlarms;
|
||||
} catch (error) {
|
||||
if (error instanceof CanceledError) return lineAlarms.value;
|
||||
console.error(`获取车站 ${station.name} 设备告警数据失败:`, error);
|
||||
|
||||
@@ -68,7 +68,8 @@ export function useLineDevicesQuery() {
|
||||
if (!lineDevices.value[station.code]) {
|
||||
lineDevices.value[station.code] = createEmptyStationDevices();
|
||||
}
|
||||
const stationDevices = lineDevices.value[station.code];
|
||||
// const stationDevices = lineDevices.value[station.code];
|
||||
const stationDevices = createEmptyStationDevices();
|
||||
|
||||
await Promise.allSettled([
|
||||
postNdmCameraPage(station.code, pageQuery, signal)
|
||||
@@ -144,6 +145,8 @@ export function useLineDevicesQuery() {
|
||||
stationDevices[DeviceType.VideoServer] = [];
|
||||
}),
|
||||
]);
|
||||
|
||||
lineDevices.value[station.code] = stationDevices;
|
||||
}
|
||||
|
||||
// console.timeEnd('useLineDevicesQuery');
|
||||
|
||||
@@ -20,7 +20,7 @@ useLineAlarmsQuery();
|
||||
|
||||
<template>
|
||||
<NGrid :cols="8" :x-gap="6" :y-gap="6" style="padding: 8px">
|
||||
<NGi v-for="station in stationList" :key="station.name">
|
||||
<NGi v-for="station in stationList" :key="station.code">
|
||||
<StationCard :station="station" :station-devices="lineDevices[station.code]" :station-alarms="lineAlarms[station.code]" />
|
||||
</NGi>
|
||||
</NGrid>
|
||||
|
||||
Reference in New Issue
Block a user