Commit fa8a9ec66e65fbd563aa49b251a7fd0f85649ac2
Merge branch 'ww' into 'main'
fix: global alarm notify can not notify See merge request huang/yun-teng-iot-front!354
Showing
3 changed files
with
10 additions
and
6 deletions
... | ... | @@ -29,7 +29,6 @@ |
29 | 29 | import { useLockPage } from '/@/hooks/web/useLockPage'; |
30 | 30 | |
31 | 31 | import { useAppInject } from '/@/hooks/web/useAppInject'; |
32 | - import { useAlarmNotify } from '/@/views/alarm/log/hook/useAlarmNotify'; | |
33 | 32 | |
34 | 33 | export default defineComponent({ |
35 | 34 | name: 'DefaultLayout', |
... | ... | @@ -58,7 +57,6 @@ |
58 | 57 | } |
59 | 58 | return cls; |
60 | 59 | }); |
61 | - useAlarmNotify(); | |
62 | 60 | return { |
63 | 61 | getShowFullHeaderRef, |
64 | 62 | getShowSidebar, | ... | ... |
... | ... | @@ -33,6 +33,7 @@ |
33 | 33 | import { useMultipleTabSetting } from '/@/hooks/setting/useMultipleTabSetting'; |
34 | 34 | import { getTransitionName } from './transition'; |
35 | 35 | import { useMultipleTabStore } from '/@/store/modules/multipleTab'; |
36 | + import { useAlarmNotify } from '/@/views/alarm/log/hook/useAlarmNotify'; | |
36 | 37 | export default defineComponent({ |
37 | 38 | name: 'PageLayout', |
38 | 39 | components: { FrameLayout }, |
... | ... | @@ -53,6 +54,8 @@ |
53 | 54 | return tabStore.getCachedTabList; |
54 | 55 | }); |
55 | 56 | |
57 | + useAlarmNotify(); | |
58 | + | |
56 | 59 | return { |
57 | 60 | getTransitionName, |
58 | 61 | openCache, | ... | ... |
... | ... | @@ -15,6 +15,10 @@ interface UseAlarmNotifyParams { |
15 | 15 | duration?: number; |
16 | 16 | } |
17 | 17 | |
18 | +export enum AlarmPermissionKey { | |
19 | + GLOBAL_NOTIFY = 'api:alarm:global:notify', | |
20 | +} | |
21 | + | |
18 | 22 | export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { |
19 | 23 | const { |
20 | 24 | alarmNotifyStatus = AlarmStatus.ACTIVE_UN_ACK, |
... | ... | @@ -94,24 +98,23 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { |
94 | 98 | const { hasPermission } = usePermission(); |
95 | 99 | |
96 | 100 | onMounted(() => { |
97 | - const alarmPermissionKey = 'api:alarm:global:notify'; | |
98 | 101 | const hasPermissionRole = [RoleEnum.CUSTOMER_USER, RoleEnum.TENANT_ADMIN]; |
99 | 102 | const userInfo = useUserStore().getUserInfo; |
100 | 103 | const userRoles = userInfo.roles || []; |
101 | 104 | |
102 | - const getPermissionFlag = () => { | |
105 | + const getRoleHasNotifyFlag = () => { | |
103 | 106 | for (const item of userRoles) { |
104 | 107 | const flag = hasPermissionRole.find((each) => item === each); |
105 | 108 | if (flag) return true; |
106 | 109 | } |
107 | 110 | return false; |
108 | 111 | }; |
109 | - if (hasPermission(alarmPermissionKey) && getPermissionFlag()) polling(); | |
112 | + | |
113 | + if (hasPermission(AlarmPermissionKey.GLOBAL_NOTIFY) && getRoleHasNotifyFlag()) polling(); | |
110 | 114 | }); |
111 | 115 | |
112 | 116 | onUnmounted(() => { |
113 | 117 | clearInterval(timeout as NodeJS.Timer); |
114 | 118 | timeout = null; |
115 | - // currentNotifyId = null; | |
116 | 119 | }); |
117 | 120 | } | ... | ... |