mirror of
https://github.com/jeecgboot/jeecg-uniapp.git
synced 2026-01-13 07:02:56 +08:00
解决[issues/497]websocket连接打开失败
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import configService from '@/common/service/config.service.js';
|
||||
import store from '@/store/index.js';
|
||||
import {ACCESS_TOKEN} from '@/common/util/constants.js'
|
||||
class socket {
|
||||
constructor(options) {
|
||||
this.socketUrl = configService.apiUrl;
|
||||
@@ -17,11 +18,15 @@ class socket {
|
||||
let userid=store.state.userid?store.state.userid:store.getters.userid;
|
||||
let url=this.socketUrl.replace("https://","wss://").replace("http://","ws://")+"/"+socket_type+"/"+userid+"_app";
|
||||
console.log("启动this.socketUrl连接地址:",url);
|
||||
|
||||
// update-begin-author:lsq date:20230506 for:[issues/497]websocket连接打开失败
|
||||
let token = uni.getStorageSync(ACCESS_TOKEN)
|
||||
uni.connectSocket({
|
||||
url: url,
|
||||
method: 'GET'
|
||||
method: 'GET',
|
||||
protocols:[token]
|
||||
});
|
||||
// update-end-author:lsq date:20230506 for:[issues/497]websocket连接打开失败
|
||||
|
||||
uni.onSocketOpen((res) => {
|
||||
this.socketStart = true;
|
||||
callback && callback();
|
||||
|
||||
Reference in New Issue
Block a user