diff --git a/src/components/ConnectInfoDialog.vue b/src/components/ConnectInfoDialog.vue new file mode 100644 index 0000000..3733ff2 --- /dev/null +++ b/src/components/ConnectInfoDialog.vue @@ -0,0 +1,80 @@ + + + diff --git a/src/components/webSocketConnect.ts b/src/components/webSocketConnect.ts new file mode 100644 index 0000000..c4881f6 --- /dev/null +++ b/src/components/webSocketConnect.ts @@ -0,0 +1,34 @@ +import { HandleMessage, StompMessagingClient } from 'jl-graphic'; +import { getJwtToken } from 'src/configs/TokenManage'; +import { getWebsocketUrl } from 'src/configs/UrlManage'; + +export function webSocketConnect( + socket: StompMessagingClient | null, + destination: string, + handler: HandleMessage +) { + socket = new StompMessagingClient({ + wsUrl: `${getWebsocketUrl()}`, + token: getJwtToken() as string, + protocol: 'protobuf', + connectTimeout: 30 * 1000, + heartbeat: 60, + retryPeriod: 2 * 1000, + retryTimes: 100, + }); + socket.on('connected', () => { + socket?.subscribe(destination, handler); + }); + socket.on('disconnected', () => { + console.log(6666); + }); +} + +export function closeWebSocketConnect( + socket: StompMessagingClient | null, + destination: string +) { + socket?.unsubscribe0(destination); + socket?.close(); + socket = null; +} diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index f3f72ba..058dea0 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -55,6 +55,14 @@ v-if="$q.screen.gt.sm" > +