|
|
@ -12,7 +12,7 @@ function guid() {
|
|
|
|
Vue.prototype.$startWebSockets = function () {
|
|
|
|
Vue.prototype.$startWebSockets = function () {
|
|
|
|
console.log();
|
|
|
|
console.log();
|
|
|
|
let token = this.$cookies.get(TOKEN_KEY);
|
|
|
|
let token = this.$cookies.get(TOKEN_KEY);
|
|
|
|
if (token&&!Vue.prototype.Socket) {
|
|
|
|
if (token && !Vue.prototype.Socket) {
|
|
|
|
let url = `wss://k8s-horse-gateway.mashibing.cn/ws?client=${token}&type=1`;
|
|
|
|
let url = `wss://k8s-horse-gateway.mashibing.cn/ws?client=${token}&type=1`;
|
|
|
|
Vue.prototype.Socket = new WebSocket(url);
|
|
|
|
Vue.prototype.Socket = new WebSocket(url);
|
|
|
|
Vue.prototype.Socket.onopen = () => {
|
|
|
|
Vue.prototype.Socket.onopen = () => {
|
|
|
@ -40,17 +40,19 @@ Vue.prototype.$startWebSockets = function () {
|
|
|
|
if (msg.traceType == 1) {
|
|
|
|
if (msg.traceType == 1) {
|
|
|
|
let traceId = guid();
|
|
|
|
let traceId = guid();
|
|
|
|
let sys = msg.content.sessionVOS.find((item) => item.type != 3);
|
|
|
|
let sys = msg.content.sessionVOS.find((item) => item.type != 3);
|
|
|
|
let str = `{"traceId":"${traceId}",traceType:2,"content":{"sessionId":${sys.id}}}`;
|
|
|
|
if (sys) {
|
|
|
|
Vue.prototype.Socket.send(str);
|
|
|
|
let str = `{"traceId":"${traceId}",traceType:2,"content":{"sessionId":${sys.id}}}`;
|
|
|
|
this.$store.commit("setUnreadCount", msg.content.totalUnreadCount);
|
|
|
|
Vue.prototype.Socket.send(str);
|
|
|
|
|
|
|
|
this.$store.commit("setUnreadCount", msg.content.totalUnreadCount);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取消息列表
|
|
|
|
// 获取消息列表
|
|
|
|
if (msg.traceType == 2) {
|
|
|
|
if (msg.traceType == 2) {
|
|
|
|
this.$store.commit("setSocketMsgData", msg.content);
|
|
|
|
this.$store.commit("setSocketMsgData", msg.content);
|
|
|
|
setTimeout(()=>{
|
|
|
|
setTimeout(() => {
|
|
|
|
console.log(this.$store.state)
|
|
|
|
console.log(this.$store.state);
|
|
|
|
},500)
|
|
|
|
}, 500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 接收消息
|
|
|
|
// 接收消息
|
|
|
|