diff --git a/apps/web/src/stores/alertStore.js b/apps/web/src/stores/alertStore.js index 804d260..2529380 100644 --- a/apps/web/src/stores/alertStore.js +++ b/apps/web/src/stores/alertStore.js @@ -84,6 +84,17 @@ export const useAlertStore = defineStore('alerts', () => { } // ---- 桌面通知 ---- + const activeNotifyOffsets = new Set() + const NOTIFY_STEP = 80 + + function getAvailableOffset() { + let offset = 0 + while (activeNotifyOffsets.has(offset)) { + offset += NOTIFY_STEP + } + return offset + } + function showDesktopNotification(alert) { const severityLabels = { critical: '严重', @@ -94,6 +105,8 @@ export const useAlertStore = defineStore('alerts', () => { } const label = severityLabels[alert.severity] || alert.severity const typeName = alert.event_type || '未知事件' + const offset = getAvailableOffset() + activeNotifyOffsets.add(offset) ElNotification({ title: `[${label}] ${typeName}`, @@ -103,10 +116,15 @@ export const useAlertStore = defineStore('alerts', () => { type: alert.severity === 'critical' || alert.severity === 'high' ? 'warning' : 'info', - duration: alert.severity === 'critical' ? 0 : 4500, + duration: 5000, + offset, + showClose: true, dangerouslyUseHTMLString: false, onClick: () => { markAsRead(alert.alert_id) + }, + onClose: () => { + activeNotifyOffsets.delete(offset) } }) } diff --git a/apps/web/src/views/AlertList.vue b/apps/web/src/views/AlertList.vue index 11c85f5..dc625b7 100644 --- a/apps/web/src/views/AlertList.vue +++ b/apps/web/src/views/AlertList.vue @@ -29,6 +29,7 @@ class="filter-control" @change="applyFilter" > + @@ -44,6 +45,7 @@ class="filter-control" @change="applyFilter" > +