优化报警推送

This commit is contained in:
648540858
2024-10-28 17:53:27 +08:00
parent c25807f65d
commit bf9262283e
6 changed files with 423 additions and 287 deletions

View File

@@ -112,17 +112,25 @@ export default {
let that = this;
if (this.alarmNotify) {
console.log("申请SSE推送API调用浏览器ID: " + this.$browserId);
this.sseSource = new EventSource('/api/emit?browserId=' + this.$browserId);
let url = (process.env.NODE_ENV === 'development' ? "debug" : "") + 'api/emit?browserId=' + this.$browserId
this.sseSource = new EventSource(url);
this.sseSource.addEventListener('message', function (evt) {
console.log("收到信息:" + evt.data);
let data = JSON.parse(evt.data)
that.$notify({
title: '报警信息',
dangerouslyUseHTMLString: true,
message: evt.data,
message: `<strong>设备:</strong> <i> ${data.deviceId}</i>` +
`<br><strong>通道编号:</strong> <i>${ data.channelId}</i>` +
`<br><strong>报警级别:</strong> <i>${ data.alarmPriorityDescription}</i>` +
`<br><strong>报警方式:</strong> <i>${ data.alarmMethodDescription}</i>` +
`<br><strong>报警类型:</strong> <i>${ data.alarmTypeDescription}</i>` +
`<br><strong>报警时间:</strong> <i>${ data.alarmTime}</i>`,
type: 'warning',
position: 'bottom-right',
duration: 3000
});
console.log("收到信息:" + evt.data);
});
this.sseSource.addEventListener('open', function (e) {
console.log("SSE连接打开.");