refactor: 抽离未读告警状态,不再持久化

This commit is contained in:
yangsy
2026-01-15 13:58:13 +08:00
parent de35075be8
commit b59b34e68b
9 changed files with 67 additions and 49 deletions
+8 -5
View File
@@ -1,6 +1,6 @@
import type { NdmDeviceAlarmLogResultVO, Station, SyncCameraResult } from '@/apis';
import { ALARM_TOPIC, SYNC_CAMERA_STATUS_TOPIC } from '@/constants';
import { useAlarmStore, useSettingStore, useStationStore } from '@/stores';
import { useSettingStore, useStationStore, useUnreadStore } from '@/stores';
import { Client } from '@stomp/stompjs';
import { watchDebounced } from '@vueuse/core';
import destr from 'destr';
@@ -19,8 +19,10 @@ const getBrokerUrl = () => {
export const useStompClient = () => {
const stationStore = useStationStore();
const { stations } = storeToRefs(stationStore);
const alarmStore = useAlarmStore();
const { unreadLineAlarms } = storeToRefs(alarmStore);
const unreadStore = useUnreadStore();
const { unreadLineAlarms } = storeToRefs(unreadStore);
const settingStore = useSettingStore();
const { offlineDev } = storeToRefs(settingStore);
@@ -40,8 +42,9 @@ export const useStompClient = () => {
console.log('Stomp连接成功');
stompClient.value?.subscribe(ALARM_TOPIC, (message) => {
const alarm = destr<NdmDeviceAlarmLogResultVO>(message.body);
if (alarm.alarmCategory === '1') {
alarmStore.pushUnreadAlarm(alarm);
const { alarmCategory, stationCode } = alarm;
if (alarmCategory === '1' && !!stations.value.find((station) => station.code === stationCode)) {
unreadStore.pushUnreadAlarm(alarm);
}
});
stompClient.value?.subscribe(SYNC_CAMERA_STATUS_TOPIC, (message) => {