diff --git a/src/stores/line-net-store.ts b/src/stores/line-net-store.ts index 975caab..0b1d48b 100644 --- a/src/stores/line-net-store.ts +++ b/src/stores/line-net-store.ts @@ -7,7 +7,7 @@ import { cancelSubscribe, } from 'src/drawApp/lineNetApp'; import { markRaw } from 'vue'; -import { Notify, QTable } from 'quasar'; +import { Notify, QNotifyUpdateOptions, QTable } from 'quasar'; import { state } from 'src/protos/system_warn_message'; export interface AlarmInfo { id: string; @@ -22,6 +22,10 @@ export interface AlarmInfo { alert_location_id: number; alarmStatus?: number; } +let msgNotify: null | ((props?: QNotifyUpdateOptions | undefined) => void) = + null; +let tip = ''; + export const useLineNetStore = defineStore('lineNet', { state: () => ({ selectedGraphics: null as JlGraphic[] | null, @@ -91,27 +95,24 @@ export const useLineNetStore = defineStore('lineNet', { }); }, setConnectInfo(data: state.WarnLineMessage) { - let tip = ''; + let newTip = ''; data.msgs.forEach((item: state.WarnMessage) => { - if (this.connectInfo) { - this.connectInfo.msgs.forEach((elem) => { - if (elem.lineId === item.lineId) { - if (elem.occRealConned && !item.occRealConned) { - tip = - tip + - `
${elem.lineId}号线路与卡斯柯的实时连接已断开;
`; - } - if (elem.occUnrealConned && !item.occUnrealConned) { - tip = - tip + - `
${elem.lineId}号线路与卡斯柯的非实时连接已断开
`; - } - } - }); + if (!item.occRealConned) { + newTip = + newTip + `
${item.lineId}号线路与卡斯柯的实时连接已断开;
`; + } + if (!item.occUnrealConned) { + newTip = + newTip + + `
${item.lineId}号线路与卡斯柯的非实时连接已断开
`; } }); - if (tip) { - const msgNotify = Notify.create({ + if (newTip && (newTip !== tip || !msgNotify)) { + if (msgNotify) { + msgNotify(); + } + tip = newTip; + msgNotify = Notify.create({ type: 'negative', timeout: 0, position: 'top', @@ -122,11 +123,17 @@ export const useLineNetStore = defineStore('lineNet', { icon: 'close', color: 'white', handler: () => { - msgNotify(); + if (msgNotify) { + msgNotify(); + } }, }, ], }); + } else if (!newTip) { + if (msgNotify) { + msgNotify(); + } } this.connectInfo = data; const allConnectAmount = data.msgs.reduce((pre, cur) => {