From ce4c7144dd232a001606c099be5823d95d89f88c Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 24 Mar 2021 17:58:20 +0800
Subject: [PATCH] Merge branch 'master' of http://s16s652780.51mypc.cn:49896/r/jfpt-Vue
---
src/page/index/top/index.vue | 6 +++++-
src/page/index/logo.vue | 40 +++++++++++++++++++++++-----------------
2 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/src/page/index/logo.vue b/src/page/index/logo.vue
index 35e5fe6..c2d3f78 100644
--- a/src/page/index/logo.vue
+++ b/src/page/index/logo.vue
@@ -372,27 +372,33 @@
if (!window.WebSocket) {
return;
}
- if (that.socket.readyState == WebSocket.OPEN) {
- that.socket.send(that.userId);
+
+ if (window.WebSocket) {
+ window.socket = new WebSocket("ws://36.134.81.48:9034/websocket");
+ window.socket.onmessage = function (event) {
+ };
+
+ window.socket.onopen = function (event) {
+ };
+
+ window.socket.onclose = function (event) {
+ };
} else {
console.log("WebSocket连接没有建立成功!!");
}
- }, 4000);
- axios({
- url: "/api/blade-jfpts/alarm/alarm/getLimit",
- method: "get",
- }).then(function (response) {
- that.deviceId = response.data.data[0].id;
- //获得最新ID,开启实时报警循环
- that.layerRealtime();
- });
- },
- layerRealtime() {
- var that = this;
- window.clearTimeout(window.realTimeQuery);
- // that.deviceId = 334; // 测试用
- window.realTimeQuery = setInterval(function () {
+ setTimeout(function () {
+ if(!window.WebSocket){
+ return;
+ }
+ if(window.socket.readyState == WebSocket.OPEN){
+ window.socket.send(that.userId);
+ }else{
+ console.log("WebSocket连接没有建立成功!!");
+ }
+ }, 2000);
+
+
axios({
url: "/api/blade-jfpts/alarm/alarm/selecttx?id=" + that.deviceId,
method: "post",
diff --git a/src/page/index/top/index.vue b/src/page/index/top/index.vue
index 395e94d..14b3f6e 100644
--- a/src/page/index/top/index.vue
+++ b/src/page/index/top/index.vue
@@ -19,7 +19,7 @@
</span>
</div>
<div class="top-bar__right">
-
+
<img src="/img/ydlg.png" style="height: 44px; vertical-align: middle;" alt="">
<el-tooltip v-if="showColor"
effect="dark"
@@ -170,6 +170,10 @@
cancelButtonText: this.$t("cancelText"),
type: "warning"
}).then(() => {
+
+ //关闭webSocket
+ window.socket.close();
+
this.$store.dispatch("LogOut").then(() => {
resetRouter();
this.$router.push({path: "/login"});
--
Gitblit v1.9.3