sock代码调整
This commit is contained in:
parent
75334d11fa
commit
2f120b8c19
@ -32,6 +32,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'$store.state.socket.beLogoutCount': async function(val) {
|
'$store.state.socket.beLogoutCount': async function(val) {
|
||||||
|
this.$store.dispatch('disconnect').then(()=>{
|
||||||
this.$alert(this.$t('tip.logoutTips'), this.$t('tip.hint'), {
|
this.$alert(this.$t('tip.logoutTips'), this.$t('tip.hint'), {
|
||||||
confirmButtonText: this.$t('tip.confirm'),
|
confirmButtonText: this.$t('tip.confirm'),
|
||||||
callback: action => {
|
callback: action => {
|
||||||
@ -40,6 +41,7 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -188,6 +188,7 @@ const user = {
|
|||||||
},
|
},
|
||||||
disconnect({commit}, params) {
|
disconnect({commit}, params) {
|
||||||
commit('Disconnect', params);
|
commit('Disconnect', params);
|
||||||
|
removeToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -44,7 +44,7 @@ service.interceptors.response.use(
|
|||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
EventBus.$emit('clearCheckLogin');
|
EventBus.$emit('clearCheckLogin');
|
||||||
// 断开连接
|
// 断开连接
|
||||||
store.dispatch('Disconnect');
|
store.dispatch('disconnect').then(()=>{
|
||||||
MessageBox.confirm(i18n.t('tip.logoutTips'), i18n.t('tip.hint'), {
|
MessageBox.confirm(i18n.t('tip.logoutTips'), i18n.t('tip.hint'), {
|
||||||
confirmButtonText: i18n.t('tip.confirmLogin'),
|
confirmButtonText: i18n.t('tip.confirmLogin'),
|
||||||
showCancelButton: false,
|
showCancelButton: false,
|
||||||
@ -54,6 +54,7 @@ service.interceptors.response.use(
|
|||||||
location.reload();// 为了重新实例化vue-router对象 避免bug
|
location.reload();// 为了重新实例化vue-router对象 避免bug
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return Promise.reject(res);
|
return Promise.reject(res);
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,8 +37,11 @@ StompClient.prototype = {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
// 建立连接对象(还未发起连接)
|
// 建立连接对象(还未发起连接)
|
||||||
// (null, {transports:['websocket']})解决连接关闭后xhr_streaming无限循环
|
// (null, {transports:['websocket']})虽可以解决连接关闭后xhr_streaming无限循环
|
||||||
this.socket = new SockJS(websocketUrl + getToken(), null, {transports:['websocket', 'MozWebSocket']});
|
// 但是该参数只会允许websockets,若不支持,直接报错
|
||||||
|
// 注意sockjs会做降级处理,优先处理websockets,若浏览器不支持websockets
|
||||||
|
// 则会降级为xhr_streaming(轮询),继续不支持的时候会降级为xhr-polling
|
||||||
|
this.socket = new SockJS(websocketUrl + getToken());
|
||||||
|
|
||||||
// 获取 STOMP 子协议的客户端对象
|
// 获取 STOMP 子协议的客户端对象
|
||||||
this.clientIns = Stomp.over(this.socket);
|
this.clientIns = Stomp.over(this.socket);
|
||||||
@ -72,6 +75,10 @@ StompClient.prototype = {
|
|||||||
this.logOut(err);
|
this.logOut(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
this.clientIns.ws.onerror = ()=>{
|
||||||
|
// debugger;
|
||||||
|
console.log(1111);
|
||||||
|
};
|
||||||
resolve(this);
|
resolve(this);
|
||||||
}, () => {
|
}, () => {
|
||||||
checkLoginLine().then(() => {
|
checkLoginLine().then(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user