move websocket globally and modify mainn page
This commit is contained in:
21
src/boot/websocket.ts
Normal file
21
src/boot/websocket.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { boot } from 'quasar/wrappers';
|
||||
import type { QVueGlobals } from 'quasar';
|
||||
import { initWebSocket } from 'src/services/websocket';
|
||||
|
||||
export default boot(({ app }) => {
|
||||
const $q = app.config.globalProperties.$q as QVueGlobals;
|
||||
|
||||
const ws = initWebSocket('ws://127.0.0.1:8100/ws?id=quasar', $q);
|
||||
app.config.globalProperties.$socket = ws;
|
||||
ws.connect();
|
||||
});
|
||||
|
||||
declare module '@vue/runtime-core' {
|
||||
interface ComponentCustomProperties {
|
||||
$socket: {
|
||||
connect: () => void;
|
||||
close: () => void;
|
||||
socket: WebSocket | null;
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user