zs 2 rokov pred
rodič
commit
3f080f0d7f
1 zmenil súbory, kde vykonal 1 pridanie a 6 odobranie
  1. 1 6
      store/websocketStore.js

+ 1 - 6
store/websocketStore.js

@@ -6,8 +6,7 @@ const store = new Vuex.Store({
 	state: {
 		socketTask: null,
 		websocketData: {}, // 存放从后端接收到的websocket数据
-		// Socket连接状态
-		IsOpen: false,
+		is_open_socket = false //避免重复连接
 	},
 	mutations: {
 		setWebsocketData(state, data) {
@@ -19,13 +18,9 @@ const store = new Vuex.Store({
 			state,
 			dispatch
 		}, url) {
-			// 防止重复连接
-			if (state.IsOpen) return;
-			// 连接
 			state.socketTask = uni.connectSocket({
 				url, // url是websocket连接ip
 				success: () => {
-					state.IsOpen == true
 					console.log('WebSocket连接成功!')
 				},
 				fail: e => {