添加浏览器ID,确保SSE可同时推送到不同的前端
This commit is contained in:
@@ -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: '收到报警信息',
|
||||
|
||||
@@ -8,10 +8,28 @@ import axios from 'axios';
|
||||
import VueCookies from 'vue-cookies';
|
||||
import echarts from 'echarts';
|
||||
|
||||
import VueClipboard from 'vue-clipboard2'
|
||||
import VueClipboard from 'vue-clipboard2';
|
||||
import { Notification } from 'element-ui';
|
||||
import Fingerprint2 from 'fingerprintjs2';
|
||||
|
||||
Vue.use(VueClipboard)
|
||||
// <20><><EFBFBD><EFBFBD>ΨһID
|
||||
Fingerprint2.get(function(components) {
|
||||
const values = components.map(function(component,index) {
|
||||
if (index === 0) { //<2F><><EFBFBD><CEA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UA<55><41>wifi<66><69>4G<34><47><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>滻<EFBFBD>ɿ<EFBFBD>,<2C><>Ȼ<EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID<49><44>һ<EFBFBD><D2BB>
|
||||
return component.value.replace(/\bNetType\/\w+\b/, '');
|
||||
}
|
||||
return component.value;
|
||||
})
|
||||
//console.log(values) //ʹ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣnpm
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>id
|
||||
let port = window.location.port;
|
||||
console.log(port);
|
||||
const fingerPrint = Fingerprint2.x64hash128(values.join(port), 31)
|
||||
Vue.prototype.$browserId = fingerPrint;
|
||||
console.log("Ψһ<CEA8><D2BB>ʶ<EFBFBD>룺" + fingerPrint);
|
||||
});
|
||||
|
||||
Vue.use(VueClipboard);
|
||||
Vue.use(ElementUI);
|
||||
Vue.use(VueCookies);
|
||||
Vue.prototype.$axios = axios;
|
||||
|
||||
Reference in New Issue
Block a user