wip: 临时提交
This commit is contained in:
16
src/plugins/websocket.ts
Normal file
16
src/plugins/websocket.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { useWebSocketDict } from "@/hooks/useWebSocketDict";
|
||||
|
||||
/**
|
||||
* 初始化WebSocket服务
|
||||
*/
|
||||
export function setupWebSocket() {
|
||||
const dictWebSocket = useWebSocketDict();
|
||||
|
||||
// 初始化字典WebSocket服务
|
||||
dictWebSocket.initWebSocket();
|
||||
|
||||
// 在窗口关闭前断开WebSocket连接
|
||||
window.addEventListener("beforeunload", () => {
|
||||
dictWebSocket.closeWebSocket();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user