添加浏览器ID,确保SSE可同时推送到不同的前端

This commit is contained in:
Lawrence
2021-01-21 19:57:57 +08:00
parent 0456d6e357
commit 4b9549dfbf
6 changed files with 92 additions and 34 deletions

View File

@@ -34,7 +34,8 @@ export default {
sseControl() {
let that = this;
if (this.alarmNotify) {
this.sseSource = new EventSource('/api/emit');
console.log("申请SSE推送API调用浏览器ID: " + this.$browserId);
this.sseSource = new EventSource('/api/emit?browserId=' + this.$browserId);
this.sseSource.addEventListener('message', function(evt) {
that.$notify({
title: '收到报警信息',