diff --git a/src/App.vue b/src/App.vue index 6c95563..f614fee 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,49 +5,56 @@ import { globalEventBus } from '@/common/eventBus' import { Push } from '@/common/push' import { areaObj } from "@/store/index.js" +import { useRouter } from 'vue-router'; +const router=useRouter() + + const userInfoStore=areaObj() userInfoStore.changeUserInfoFn(510521) -// var connection = new Push({ -// url: 'ws://192.168.1.10:3131', // websocket地址 -// app_key: 'aaea61749929eb53a4bd75a1474c1d27', -// }); -// // 假设用户uid为1 -// var uid = 3; -// // 浏览器监听user-2频道的消息,也就是用户uid为1的用户消息 -// var user_channel = connection.subscribe('user-' + uid); +var connection = new Push({ + url: 'wss://chat.lihaink.cn/tts', // websocket地址 + app_key: 'aaea61749929eb53a4bd75a1474c1d27', +}); +// 假设用户uid为1 +var uid = 3; +// 浏览器监听user-2频道的消息,也就是用户uid为1的用户消息 +var user_channel = connection.subscribe('user-' + uid); -// // 当user-2频道有message事件的消息时 -// user_channel.on('message', function (data) { -// globalEventBus.emit(data.content.event, data.content.data) - - -// console.log("收到消息",data) - -// }); -// // 断线事件 -// user_channel.on('close', function () { - -// }); +// 当user-2频道有message事件的消息时 +user_channel.on('message', function (data) { -var ws = new WebSocket("ws://192.168.26.167:8080"); + globalEventBus.emit(data.content.event, data.content.data) +}); +// 断线事件 +user_channel.on('close', function () { -//当WebSocket创建成功时,触发onopen事件 -ws.onopen = function () { - console.log("open"); -} -//当客户端收到服务端发来的消息时,触发onmessage事件,参数e.data包含server传递过来的数据 -ws.onmessage = function (e) { - - let data =JSON.parse(e.data) - - globalEventBus.emit(data.event, data.data ||'') +}); -} +globalEventBus.on('refresh', data => { + router.go(0) +}) + +// var ws = new WebSocket("ws://192.168.26.167:8080"); + +// //当WebSocket创建成功时,触发onopen事件 +// ws.onopen = function () { +// console.log("open"); +// } +// //当客户端收到服务端发来的消息时,触发onmessage事件,参数e.data包含server传递过来的数据 +// ws.onmessage = function (e) { + +// let data =JSON.parse(e.data) + +// globalEventBus.emit(data.event, data.data ||'') + + + +// }