remove chat debug log

This commit is contained in:
RockYang
2024-07-28 18:55:17 +08:00
parent abdf5298fe
commit 1bcbf74883
4 changed files with 16 additions and 21 deletions

View File

@@ -94,7 +94,7 @@
</template>
<script setup>
import {nextTick, onMounted, onUnmounted, ref} from 'vue';
import {nextTick, onUnmounted, ref} from 'vue';
import {Markmap} from 'markmap-view';
import {Transformer} from 'markmap-lib';
import {checkSession} from "@/action/session";
@@ -209,7 +209,6 @@ window.onresize = () => {
}
const socket = ref(null)
const heartbeatHandle = ref(0)
const connect = (userId) => {
if (socket.value !== null) {
socket.value.close()
@@ -224,24 +223,9 @@ const connect = (userId) => {
}
}
// 心跳函数
const sendHeartbeat = () => {
clearTimeout(heartbeatHandle.value)
new Promise((resolve, reject) => {
if (socket.value !== null) {
socket.value.send(JSON.stringify({type: "heartbeat", content: "ping"}))
}
resolve("success")
}).then(() => {
heartbeatHandle.value = setTimeout(() => sendHeartbeat(), 5000)
});
}
const _socket = new WebSocket(host + `/api/markMap/client?user_id=${userId}&model_id=${modelID.value}`);
_socket.addEventListener('open', () => {
socket.value = _socket;
// 发送心跳消息
sendHeartbeat()
});
_socket.addEventListener('message', event => {