websocket

This commit is contained in:
2024-04-16 10:37:57 +08:00
parent 10b3a66ea3
commit eee16a835b
2 changed files with 8 additions and 4 deletions

View File

@@ -101,7 +101,11 @@ export function sendWebsocket (url, agentData, successCallback, errCallback) {
/**
* 关闭websocket函数
*/
export function closeWebsocket () {
export function closeWebsocket (flag) {
if (flag) {
websock.close()
return
}
if (websock) {
websock.close() // 关闭websocket
websock.onclose() // 关闭websocket

View File

@@ -263,11 +263,11 @@ export default {
}
},
beforeDestroy () {
clearInterval(this.timer)
clearTimeout(this.timer)
closeWebsocket(true)
},
destroyed () {
clearInterval(this.timer)
clearTimeout(this.timer)
},
methods: {
handleSelect (key) {
@@ -372,7 +372,7 @@ export default {
},
wsMessage (res) {
// console.log(res)
clearInterval(this.timer)
clearTimeout(this.timer)
let data = res.head
this.$store.dispatch('materObj', res.home.result)
if (data.code === '1') {