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