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