|
@@ -2,6 +2,8 @@ import {ElMessageBox} from 'element-plus'
|
|
|
import Cookies from 'js-cookie'
|
|
|
import router from '@/router'
|
|
|
import store from '@/store'
|
|
|
+import SoctetDialog from "@/components/xiao-chan/websocket/SoctetDialog.vue";
|
|
|
+import {createApp} from 'vue'
|
|
|
|
|
|
const socketUrl = import.meta.env.VITE_SOCKET_URL
|
|
|
|
|
@@ -39,8 +41,9 @@ function sendAMessage(name, data) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export function initWebSocket(sid, force) {
|
|
|
+export const socketErrDialog = ref(false)
|
|
|
|
|
|
+export function initWebSocket(sid, force) {
|
|
|
if ('WebSocket' in window) {
|
|
|
if (webSocket === null || force) {
|
|
|
const url = socketUrl + sid
|
|
@@ -52,16 +55,17 @@ export function initWebSocket(sid, force) {
|
|
|
}
|
|
|
|
|
|
webSocket.onopen = function () {
|
|
|
+ socketErrDialog.value = false
|
|
|
console.log('WebSocket连接成功')
|
|
|
}
|
|
|
|
|
|
-
|
|
|
webSocket.onmessage = function (e) {
|
|
|
let data = JSON.parse(e.data)
|
|
|
sendAMessage(data.name, data.message)
|
|
|
}
|
|
|
|
|
|
webSocket.onclose = function () {
|
|
|
+ socketErrDialog.value = true
|
|
|
webSocket = null
|
|
|
let sid
|
|
|
if (router.currentRoute.value.path === '/triageRoomScreen') {
|