From 117aadb12c2bb9867b0e48939ee1a412eef5a7b9 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Wed, 24 Mar 2021 22:35:47 +0800
Subject: [PATCH] webSocket调整,改为在请求页调用,防止关闭后自动登录的情况
---
src/page/index/logo.vue | 43 ++++++++++++++-----------------------------
1 files changed, 14 insertions(+), 29 deletions(-)
diff --git a/src/page/index/logo.vue b/src/page/index/logo.vue
index c2d3f78..18b89eb 100644
--- a/src/page/index/logo.vue
+++ b/src/page/index/logo.vue
@@ -358,47 +358,32 @@
}
if (window.WebSocket) {
- that.socket = new WebSocket("ws://36.134.81.48:9034/websocket");
- that.socket.onmessage = function (event) {};
+ window.socket = new WebSocket("ws://36.134.81.48:9034/websocket");
+ window.socket.onmessage = function (event) {
+ };
- that.socket.onopen = function (event) {};
+ window.socket.onopen = function (event) {
+ };
- that.socket.onclose = function (event) {};
+ window.socket.onclose = function (event) {
+ };
} else {
- console.log("您的浏览器不支持WebSocket");
+ console.log("WebSocket连接没有建立成功!!");
}
setTimeout(function () {
- if (!window.WebSocket) {
+ if(!window.WebSocket){
return;
}
-
- 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 {
+ if(window.socket.readyState == WebSocket.OPEN){
+ window.socket.send(that.userId);
+ }else{
console.log("WebSocket连接没有建立成功!!");
}
-
- setTimeout(function () {
- if(!window.WebSocket){
- return;
- }
- if(window.socket.readyState == WebSocket.OPEN){
- window.socket.send(that.userId);
- }else{
- console.log("WebSocket连接没有建立成功!!");
- }
- }, 2000);
+ }, 2000);
+ setTimeout(function () {
axios({
url: "/api/blade-jfpts/alarm/alarm/selecttx?id=" + that.deviceId,
method: "post",
--
Gitblit v1.9.3