From a37b110a7fa482800b3b6bf494c5329e7d75ab96 Mon Sep 17 00:00:00 2001 From: zhanjiesheng <210466500@qq.com> Date: Tue, 16 Jun 2026 17:27:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E8=AD=A6=E5=88=97=E8=A1=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E2=80=9D=E5=85=A8=E9=83=A8=E2=80=9D=E5=88=86=E7=B1=BB?= =?UTF-8?q?=EF=BC=8C=E9=A2=84=E8=AD=A6=E6=B6=88=E6=81=AF=E5=BC=B9=E7=AA=97?= =?UTF-8?q?5=E7=A7=92=E5=90=8E=E8=87=AA=E5=8A=A8=E6=B6=88=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/stores/alertStore.js | 20 +++++++++++++++++++- apps/web/src/views/AlertList.vue | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) 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" > +