...
|
...
|
@@ -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
|
} |
...
|
...
|
|