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函数 * 关闭websocket函数
*/ */
export function closeWebsocket () { export function closeWebsocket (flag) {
if (flag) {
websock.close()
return
}
if (websock) { if (websock) {
websock.close() // 关闭websocket websock.close() // 关闭websocket
websock.onclose() // 关闭websocket websock.onclose() // 关闭websocket

View File

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