opt: close unused websocket connections

This commit is contained in:
RockYang
2024-04-30 22:54:39 +08:00
parent 7bb76d581c
commit cc1a3ce343
17 changed files with 144 additions and 85 deletions

View File

@@ -276,14 +276,7 @@
<script setup>
import {nextTick, onMounted, onUnmounted, ref} from "vue";
import {
showConfirmDialog,
showFailToast,
showNotify,
showToast,
showImagePreview,
showSuccessToast
} from "vant";
import {showConfirmDialog, showFailToast, showImagePreview, showNotify, showSuccessToast, showToast} from "vant";
import {httpGet, httpPost} from "@/utils/http";
import Compressor from "compressorjs";
import {getSessionId} from "@/store/session";
@@ -364,8 +357,11 @@ onMounted(() => {
})
onUnmounted(() => {
socket.value = null
clipboard.value.destroy()
if (socket.value !== null) {
socket.value.close()
socket.value = null
}
})
const mjPower = ref(1)

View File

@@ -221,7 +221,8 @@ import {checkSession} from "@/action/session";
import {useRouter} from "vue-router";
import {getSessionId} from "@/store/session";
import {
showConfirmDialog, showDialog,
showConfirmDialog,
showDialog,
showFailToast,
showImagePreview,
showNotify,
@@ -357,7 +358,10 @@ onMounted(() => {
onUnmounted(() => {
clipboard.value.destroy()
socket.value = null
if (socket.value !== null) {
socket.value.close()
socket.value = null
}
})