预警列表添加”全部”分类,预警消息弹窗5秒后自动消失

This commit is contained in:
2026-06-16 17:27:18 +08:00
parent 7396889f32
commit a37b110a7f
2 changed files with 21 additions and 1 deletions
+19 -1
View File
@@ -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) { function showDesktopNotification(alert) {
const severityLabels = { const severityLabels = {
critical: '严重', critical: '严重',
@@ -94,6 +105,8 @@ export const useAlertStore = defineStore('alerts', () => {
} }
const label = severityLabels[alert.severity] || alert.severity const label = severityLabels[alert.severity] || alert.severity
const typeName = alert.event_type || '未知事件' const typeName = alert.event_type || '未知事件'
const offset = getAvailableOffset()
activeNotifyOffsets.add(offset)
ElNotification({ ElNotification({
title: `[${label}] ${typeName}`, title: `[${label}] ${typeName}`,
@@ -103,10 +116,15 @@ export const useAlertStore = defineStore('alerts', () => {
type: alert.severity === 'critical' || alert.severity === 'high' type: alert.severity === 'critical' || alert.severity === 'high'
? 'warning' ? 'warning'
: 'info', : 'info',
duration: alert.severity === 'critical' ? 0 : 4500, duration: 5000,
offset,
showClose: true,
dangerouslyUseHTMLString: false, dangerouslyUseHTMLString: false,
onClick: () => { onClick: () => {
markAsRead(alert.alert_id) markAsRead(alert.alert_id)
},
onClose: () => {
activeNotifyOffsets.delete(offset)
} }
}) })
} }
+2
View File
@@ -29,6 +29,7 @@
class="filter-control" class="filter-control"
@change="applyFilter" @change="applyFilter"
> >
<el-option label="全部" value="" />
<el-option label="严重" value="critical" /> <el-option label="严重" value="critical" />
<el-option label="高危" value="high" /> <el-option label="高危" value="high" />
<el-option label="中等" value="medium" /> <el-option label="中等" value="medium" />
@@ -44,6 +45,7 @@
class="filter-control" class="filter-control"
@change="applyFilter" @change="applyFilter"
> >
<el-option label="全部" value="" />
<el-option label="火灾" value="fire" /> <el-option label="火灾" value="fire" />
<el-option label="烟雾" value="smoke" /> <el-option label="烟雾" value="smoke" />
<el-option label="抽烟" value="smoking" /> <el-option label="抽烟" value="smoking" />