From b5e110081c714f28be5b3d1c9f7ab0b0b79cc7c9 Mon Sep 17 00:00:00 2001 From: republicline <1464474399@qq.com> Date: Wed, 25 Jun 2025 19:56:29 +0800 Subject: [PATCH] =?UTF-8?q?commit:=20pre-=E4=BA=8C=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/remote-ws-store.ts | 80 +++++++++++-- src/views/remote-manage/remote-control.vue | 124 ++++++++++++++++++++- vite.config.ts | 8 +- 3 files changed, 194 insertions(+), 18 deletions(-) diff --git a/src/stores/remote-ws-store.ts b/src/stores/remote-ws-store.ts index 7a82a5d..c0bf1ce 100644 --- a/src/stores/remote-ws-store.ts +++ b/src/stores/remote-ws-store.ts @@ -2,12 +2,17 @@ import {defineStore} from "pinia"; import {Session} from "@/utils/storage"; import {ElMessage, ElMessageBox} from "element-plus"; -// 本地调试版本: -const vitalUrl = "ws://" + window.location.host + "/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken() -// const medicineUrl = "ws://" + window.location.host + "/socket.io/admin/rax/addMedicine?token=" + Session.getToken() -const chatUrl = "ws://" + window.location.host + "/socket.io/admin/rax/chatRoom?token=" + Session.getToken() +// // 本地调试版本: +// const vitalUrl = "ws://" + window.location.host + "/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken() +// // const medicineUrl = "ws://" + window.location.host + "/socket.io/admin/rax/addMedicine?token=" + Session.getToken() +// const chatUrl = "ws://" + window.location.host + "/socket.io/admin/rax/chatRoom?token=" + Session.getToken() +// 服务器部署版本 +const vitalUrl = "ws://" + window.location.host + "/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken() +const medicineUrl = "ws://" + window.location.host + "/socket.io/admin/rax/addMedicine?token=" + Session.getToken() +const chatUrl = "ws://" + window.location.host + "/socket.io/admin/rax/chatRoom?token=" + Session.getToken() + // 服务器部署版本 // const vitalUrl = "wss://" + window.location.host + "/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken() // // const medicineUrl = "wss://" + window.location.host + "/socket.io/admin/rax/addMedicine?token=" + Session.getToken() @@ -192,6 +197,7 @@ export const useRemoteWsStore = defineStore("remoteWs", { disconnect(name: string, id: string, date: string, index: number) { this.disconnectChat(name, id, date, index) this.disconnectVital(name, id, date, index) + this.disconnectMedicine(name, id, date, index) delete this.patient[name + id + date + index] }, createVital(name: string, id: string, date: string, index: number) { @@ -395,6 +401,39 @@ export const useRemoteWsStore = defineStore("remoteWs", { }) } }, + + medicineOnclose(name: string, id: string, date: string, index: number, cb: any) { + const patient: any = this.patient[name + id + date + index] + patient.medicineWS.onclose = cb + }, + unsubscribeMedicine(name: string, id: string, date: string, index: number) { + const patient: any = this.patient[name + id + date + index] + patient.medicineCB = undefined; + patient.medicineWS.onmessage = undefined; + }, + + /** + * 远程控制 + */ + // 初始化 + createMedicineConnect(name: string, id: string, index: number) { + if (!this.patient[name + id + index]) this.patient[name + id + index] = {} + const patient = this.patient[name + id + index] + if (!patient['medicineWS']) { + patient['medicineWS'] = new WebSocket(medicineUrl) + patient.medicineWS.onopen = function () { + patient.medicineWS.send(JSON.stringify({ + patientName: name, + idNum: id, + // date: date, + msgType: "init" + })) + if (this.loopSendMedicinePing) { + this.loopSendMedicinePing(name,id,index,()=>{}) + } + } + } + }, subscribeMedicine(name: string, id: string, date: string, index: number, cb: any) { const patient = this.patient[name + id + date + index] if (patient) { @@ -416,14 +455,33 @@ export const useRemoteWsStore = defineStore("remoteWs", { }) } }, - medicineOnclose(name: string, id: string, date: string, index: number, cb: any) { + disconnectMedicine(name: string, id: string, date: string, index: number) { const patient: any = this.patient[name + id + date + index] - patient.medicineWS.onclose = cb + if (patient && patient.vitalWS) { + this.closeStatus[name + id + date + index + 'vitalWS'] = true + patient.medicineWS.close() + delete patient['medicineWS'] + } + }, + // 请求连接远程控制 + reqMedicineConnect(params:{name: string, id: string,index: number, msgType: string, flag: string},cb:any){ + const {name, id, index,msgType,flag} = params; + const patient = this.patient[name + id +index] + const sendData={ + patientName: name, + idNum: id, + // date: date, + msgType: msgType, + webConnectionFlag: flag + } + if (patient) { + patient.medicineWS.send(JSON.stringify(sendData)) + } + if (flag==='0') { + setTimeout(() => { + cb(flag) + }, 100); + } }, - unsubscribeMedicine(name: string, id: string, date: string, index: number) { - const patient: any = this.patient[name + id + date + index] - patient.medicineCB = undefined; - patient.medicineWS.onmessage = undefined; - } } }) diff --git a/src/views/remote-manage/remote-control.vue b/src/views/remote-manage/remote-control.vue index 36bcc67..6529c5b 100644 --- a/src/views/remote-manage/remote-control.vue +++ b/src/views/remote-manage/remote-control.vue @@ -49,6 +49,12 @@ 患者信息 + 连接远程控制 + + @@ -219,7 +225,7 @@