fix(报警推送): 修复报警推送功能无效的问题
该问题原因为 com.genersoft.iot.vmp.conf.GlobalResponseAdvice 类改变了 sse 响应体的数据结构,导致前端无法正确解析 sse 数据,调试后未发现 GlobalResponseAdvice 如何修改的 sse 数据结构,故根据 sse 消息体结构自定义实现了 sse 连接
This commit is contained in:
@@ -37,7 +37,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import changePasswordDialog from '../components/dialog/changePassword.vue'
|
||||
import userService from '../components/service/UserService'
|
||||
import {Notification} from 'element-ui';
|
||||
@@ -55,18 +54,19 @@ export default {
|
||||
};
|
||||
},
|
||||
created() {
|
||||
console.log(4444)
|
||||
console.log(JSON.stringify(userService.getUser()))
|
||||
if (this.$route.path.startsWith("/channelList")) {
|
||||
this.activeIndex = "/deviceList"
|
||||
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
window.addEventListener('beforeunload', e => this.beforeunloadHandler(e))
|
||||
// window.addEventListener('unload', e => this.unloadHandler(e))
|
||||
this.alarmNotify = this.getAlarmSwitchStatus() === "true";
|
||||
this.sseControl();
|
||||
|
||||
// TODO: 此处延迟连接 sse, 避免 sse 连接时 browserId 还未生成, 后续待优化
|
||||
setTimeout(() => {
|
||||
this.sseControl()
|
||||
}, 3000);
|
||||
},
|
||||
methods: {
|
||||
loginout() {
|
||||
@@ -107,10 +107,12 @@ export default {
|
||||
this.sseSource = new EventSource('/api/emit?browserId=' + this.$browserId);
|
||||
this.sseSource.addEventListener('message', function (evt) {
|
||||
that.$notify({
|
||||
title: '收到报警信息',
|
||||
title: '报警信息',
|
||||
dangerouslyUseHTMLString: true,
|
||||
message: evt.data,
|
||||
type: 'warning'
|
||||
type: 'warning',
|
||||
position: 'bottom-right',
|
||||
duration: 3000
|
||||
});
|
||||
console.log("收到信息:" + evt.data);
|
||||
});
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
import Vue from 'vue';
|
||||
import App from './App.vue';
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
import ElementUI from 'element-ui';
|
||||
import ElementUI, {Notification} from 'element-ui';
|
||||
import 'element-ui/lib/theme-chalk/index.css';
|
||||
import router from './router/index.js';
|
||||
import axios from 'axios';
|
||||
import VueCookies from 'vue-cookies';
|
||||
import echarts from 'echarts';
|
||||
import VCharts from 'v-charts';
|
||||
|
||||
import VueClipboard from 'vue-clipboard2';
|
||||
import {Notification} from 'element-ui';
|
||||
import Fingerprint2 from 'fingerprintjs2';
|
||||
import VueClipboards from 'vue-clipboards';
|
||||
import Contextmenu from "vue-contextmenujs"
|
||||
import userService from "./components/service/UserService"
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
|
||||
|
||||
// 生成唯一ID
|
||||
Fingerprint2.get(function (components) {
|
||||
@@ -29,10 +27,9 @@ Fingerprint2.get(function (components) {
|
||||
//console.log(values) //使用的浏览器信息npm
|
||||
// 生成最终id
|
||||
let port = window.location.port;
|
||||
console.log(port);
|
||||
const fingerPrint = Fingerprint2.x64hash128(values.join(port), 31)
|
||||
Vue.prototype.$browserId = fingerPrint;
|
||||
console.log("唯一标识码:" + fingerPrint);
|
||||
console.log("浏览器 ID: " + fingerPrint);
|
||||
});
|
||||
|
||||
Vue.use(VueClipboard);
|
||||
@@ -75,7 +72,7 @@ axios.interceptors.request.use(
|
||||
);
|
||||
|
||||
Vue.prototype.$axios = axios;
|
||||
Vue.prototype.$cookies.config(60*30);
|
||||
Vue.prototype.$cookies.config(60 * 30);
|
||||
|
||||
new Vue({
|
||||
router: router,
|
||||
|
||||
Reference in New Issue
Block a user