JeecgBoot 2.3 里程碑版本发布,支持微服务和单体自由切换、提供新行编辑表格JVXETable

This commit is contained in:
zhangdaiscott
2020-09-13 18:23:23 +08:00
parent 65d1e6a879
commit 7f30a186df
533 changed files with 187550 additions and 36942 deletions

View File

@ -1,4 +1,7 @@
import store from '@/store/'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import Vue from 'vue'
export const WebsocketMixin = {
mounted() {
this.initWebSocket();
@ -9,6 +12,7 @@ export const WebsocketMixin = {
},
methods:{
initWebSocket: function () {
let token = Vue.ls.get(ACCESS_TOKEN)
console.log("------------WebSocket连接成功");
// WebSocket与普通的请求所用协议有所不同ws等同于httpwss等同于https
var userId = store.getters.userInfo.id;
@ -18,7 +22,7 @@ export const WebsocketMixin = {
if(!this.socketUrl.endsWith('/')){
this.socketUrl = this.socketUrl + '/'
}
var url = window._CONFIG['domianURL'].replace("https://","wss://").replace("http://","ws://") + this.socketUrl + userId;
var url = window._CONFIG['domianURL'].replace("https://","wss://").replace("http://","ws://") + this.socketUrl + userId + "/" + token;
this.websock = new WebSocket(url);
this.websock.onopen = this.websocketOnopen;
this.websock.onerror = this.websocketOnerror;