@@ -172,14 +172,20 @@ const wsClient = useWebSocket(import.meta.env.VITE_WEBSOCKET_URL as string, {
interval: 1000,
pongTimeout: 1000,
},
+ onConnected: () => {
+ console.log("长链接成功");
+ },
+ onDisconnected: () => {
+ console.log("长链接断开");
onMessage: (msg) => {
console.log("长链接的消息", msg);
});
-// onMounted(() => {
-//
-// });
+onMounted(() => {
+ wsClient.open();
+});
onBeforeUnmount(() => {
wsClient.close();