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