Commit f859370e authored by 沈翠玲's avatar 沈翠玲

websocket修改

parent cd5986e5
......@@ -11,10 +11,12 @@ const useSocketStore = defineStore('socket', {
timerHeart: undefined,
timerServerHeart: undefined,
handClose: false,
url: '',
msg: '',
}),
actions: {
connection(url, token) {
this.url = url
if ('WebSocket' in window) {
this.createWebSocket(url, token);
} else {
......@@ -93,7 +95,7 @@ const useSocketStore = defineStore('socket', {
//没连上会一直重连, 设置迟延,避免请求过多
this.timerReconnect = setTimeout(() => {
//setTimeout 到点了执行
this.connection();
this.connection(this.url);
this.lockReconnect = false;
}, 5000);
},
......@@ -135,7 +137,6 @@ const useSocketStore = defineStore('socket', {
console.log('手动关闭ws');
this.handClose = true;
this.clearTimer();
console.log('ws', this.ws);
if (this.ws && this.ws.close) {
this.ws.close();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment