Commit 55550f5804b7e4f8dc4c9f29db226dbf88480626
1 parent
eeb8e4d1
fix: global alarm not notify on switch page
Showing
1 changed file
with
11 additions
and
7 deletions
| @@ -27,8 +27,6 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | @@ -27,8 +27,6 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | ||
| 27 | 27 | ||
| 28 | let timeout: Nullable<NodeJS.Timer> = null; | 28 | let timeout: Nullable<NodeJS.Timer> = null; | 
| 29 | 29 | ||
| 30 | - let currentNotifyId: Nullable<string> = null; | ||
| 31 | - | ||
| 32 | const getAlarmLog = async () => { | 30 | const getAlarmLog = async () => { | 
| 33 | try { | 31 | try { | 
| 34 | const { items = [] } = | 32 | const { items = [] } = | 
| @@ -37,12 +35,12 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | @@ -37,12 +35,12 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | ||
| 37 | if (items.length) { | 35 | if (items.length) { | 
| 38 | const first = items.at(0)!; | 36 | const first = items.at(0)!; | 
| 39 | const { deviceName, id, severity } = first; | 37 | const { deviceName, id, severity } = first; | 
| 40 | - if (currentNotifyId === id) return; | ||
| 41 | - currentNotifyId = id; | ||
| 42 | 38 | ||
| 43 | - const key = `open-notify-${Date.now()}`; | 39 | + let key: Nullable<string> = `open-notify-${id}`; | 
| 44 | 40 | ||
| 45 | const severityMean = alarmLevel(severity); | 41 | const severityMean = alarmLevel(severity); | 
| 42 | + | ||
| 43 | + console.log('enter'); | ||
| 46 | notification.open({ | 44 | notification.open({ | 
| 47 | message: '设备告警', | 45 | message: '设备告警', | 
| 48 | duration: null, | 46 | duration: null, | 
| @@ -62,7 +60,11 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | @@ -62,7 +60,11 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | ||
| 62 | ]), | 60 | ]), | 
| 63 | ]), | 61 | ]), | 
| 64 | icon: h(ExclamationCircleOutlined, { style: { color: '#faa22d' } }), | 62 | icon: h(ExclamationCircleOutlined, { style: { color: '#faa22d' } }), | 
| 65 | - onClose: () => (currentNotifyId = null), | 63 | + onClose: () => { | 
| 64 | + console.log('enter close'); | ||
| 65 | + // currentNotifyId = null; | ||
| 66 | + key = null; | ||
| 67 | + }, | ||
| 66 | btn: h( | 68 | btn: h( | 
| 67 | Button, | 69 | Button, | 
| 68 | { | 70 | { | 
| @@ -70,7 +72,8 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | @@ -70,7 +72,8 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | ||
| 70 | size: 'small', | 72 | size: 'small', | 
| 71 | onClick: async () => { | 73 | onClick: async () => { | 
| 72 | await handleMarkRead(id); | 74 | await handleMarkRead(id); | 
| 73 | - notification.close(key); | 75 | + notification.close(key!); | 
| 76 | + key = null; | ||
| 74 | }, | 77 | }, | 
| 75 | }, | 78 | }, | 
| 76 | () => '标记已读' | 79 | () => '标记已读' | 
| @@ -93,5 +96,6 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | @@ -93,5 +96,6 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | ||
| 93 | onUnmounted(() => { | 96 | onUnmounted(() => { | 
| 94 | clearInterval(timeout as NodeJS.Timer); | 97 | clearInterval(timeout as NodeJS.Timer); | 
| 95 | timeout = null; | 98 | timeout = null; | 
| 99 | + // currentNotifyId = null; | ||
| 96 | }); | 100 | }); | 
| 97 | } | 101 | } |