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 | 27 | |
28 | 28 | let timeout: Nullable<NodeJS.Timer> = null; |
29 | 29 | |
30 | - let currentNotifyId: Nullable<string> = null; | |
31 | - | |
32 | 30 | const getAlarmLog = async () => { |
33 | 31 | try { |
34 | 32 | const { items = [] } = |
... | ... | @@ -37,12 +35,12 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { |
37 | 35 | if (items.length) { |
38 | 36 | const first = items.at(0)!; |
39 | 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 | 41 | const severityMean = alarmLevel(severity); |
42 | + | |
43 | + console.log('enter'); | |
46 | 44 | notification.open({ |
47 | 45 | message: '设备告警', |
48 | 46 | duration: null, |
... | ... | @@ -62,7 +60,11 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { |
62 | 60 | ]), |
63 | 61 | ]), |
64 | 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 | 68 | btn: h( |
67 | 69 | Button, |
68 | 70 | { |
... | ... | @@ -70,7 +72,8 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { |
70 | 72 | size: 'small', |
71 | 73 | onClick: async () => { |
72 | 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 | 96 | onUnmounted(() => { |
94 | 97 | clearInterval(timeout as NodeJS.Timer); |
95 | 98 | timeout = null; |
99 | + // currentNotifyId = null; | |
96 | 100 | }); |
97 | 101 | } | ... | ... |