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) {
|
'$store.state.socket.beLogoutCount': async function(val) {
|
||||||
this.$alert(this.$t('tip.logoutTips'), this.$t('tip.hint'), {
|
this.$store.dispatch('disconnect').then(()=>{
|
||||||
confirmButtonText: this.$t('tip.confirm'),
|
this.$alert(this.$t('tip.logoutTips'), this.$t('tip.hint'), {
|
||||||
callback: action => {
|
confirmButtonText: this.$t('tip.confirm'),
|
||||||
this.$store.dispatch('exit').then(resp => {
|
callback: action => {
|
||||||
this.$router.push({path: loginInfo[getSessionStorage('project')].loginPath});
|
this.$store.dispatch('exit').then(resp => {
|
||||||
});
|
this.$router.push({path: loginInfo[getSessionStorage('project')].loginPath});
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -188,6 +188,7 @@ const user = {
|
|||||||
},
|
},
|
||||||
disconnect({commit}, params) {
|
disconnect({commit}, params) {
|
||||||
commit('Disconnect', params);
|
commit('Disconnect', params);
|
||||||
|
removeToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -44,14 +44,15 @@ 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,
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
store.dispatch('FedLogOut').then(() => {
|
store.dispatch('FedLogOut').then(() => {
|
||||||
location.reload();// 为了重新实例化vue-router对象 避免bug
|
location.reload();// 为了重新实例化vue-router对象 避免bug
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -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