预警列表添加”全部”分类,预警消息弹窗5秒后自动消失
This commit is contained in:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
class="filter-control"
|
||||
@change="applyFilter"
|
||||
>
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="严重" value="critical" />
|
||||
<el-option label="高危" value="high" />
|
||||
<el-option label="中等" value="medium" />
|
||||
@@ -44,6 +45,7 @@
|
||||
class="filter-control"
|
||||
@change="applyFilter"
|
||||
>
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="火灾" value="fire" />
|
||||
<el-option label="烟雾" value="smoke" />
|
||||
<el-option label="抽烟" value="smoking" />
|
||||
|
||||
Reference in New Issue
Block a user