mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-23 20:44:58 +08:00
add: 添加连接远程控制代码逻辑
This commit is contained in:
parent
a946727844
commit
02d3692582
|
@ -292,6 +292,41 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 请求连接远程控制
|
||||
reqMedicineConnect(name: string, id: string, date: string, index: number, msg: string, flag: string): Promise<number> {
|
||||
if (!this.patient[name + id + date + index]) this.patient[name + id + date + index] = {}
|
||||
const patient = this.patient[name + id + date + 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: msg,
|
||||
webConnectionFlag: flag
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
patient.medicineWS.onmessage = (e: any) => {
|
||||
const msg = JSON.parse(e.data)
|
||||
if (msg && msg.msgType === 'unityResponseConnection') {
|
||||
if (msg.unityConnectionFlag === '1') {
|
||||
// unity回应 连接成功
|
||||
resolve(1);
|
||||
}
|
||||
if (msg.unityConnectionFlag === '0') {
|
||||
// unity回应连接失败, or unity请求断连
|
||||
resolve(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
subscribeMedicine(name: string, id: string, date: string, index: number, cb: any) {
|
||||
const patient = this.patient[name + id + date + index]
|
||||
if (patient) {
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
</el-text>
|
||||
</el-space>
|
||||
<el-button color="#C77000" @click="viewPatientInfo">患者信息</el-button>
|
||||
<el-button color="#C77000" @click="connectRemote" v-if="!whetherControl">连接远程控制</el-button>
|
||||
<el-button color="#C77000" @click="connectionUnity" v-if="!whetherControl">连接远程控制</el-button>
|
||||
<el-button color="#C77000" v-if="whetherControl">已控制</el-button>
|
||||
<el-button color="#C77000" @click="disconnectControl">断开远程控制</el-button>
|
||||
|
||||
|
@ -293,6 +293,16 @@ function createConnect() {
|
|||
remoteWsStore.createMedicineConnect(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index)
|
||||
}
|
||||
|
||||
|
||||
// 连接远程控制
|
||||
function connectionUnity(){
|
||||
console.log("连接远程控制");
|
||||
remoteWsStore.reqMedicineConnect(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index,
|
||||
"webRequestConnection","1");
|
||||
}
|
||||
|
||||
|
||||
|
||||
function disconnect() {
|
||||
remoteWsStore.disconnectMedicine(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index)
|
||||
remoteWsStore.disconnectChat(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index)
|
||||
|
@ -311,6 +321,9 @@ function subscribeWS() {
|
|||
subscribeMedicine()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const subscribeVital = () => {
|
||||
onVitalClose()
|
||||
remoteWsStore.subscribeVital(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index,
|
||||
|
@ -340,7 +353,7 @@ const connectRemote = () => {
|
|||
const clostHandle = () => {
|
||||
console.log("ws关闭成功啦")
|
||||
}
|
||||
const messageHandle = ({data}) => {
|
||||
const messageHandle = () => {
|
||||
console.log("前端接受到的信息啦")
|
||||
}
|
||||
const errorHandle = () => {
|
||||
|
|
|
@ -6,7 +6,7 @@ import vue from '@vitejs/plugin-vue'
|
|||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
base: '/medical/',
|
||||
base: '/',
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
alias: {
|
||||
|
@ -25,13 +25,14 @@ export default defineConfig({
|
|||
'/api': {
|
||||
//target: 'http://localhost:9999', // 目标服务器地址
|
||||
//target: 'http://192.168.1.105:6379', // 目标服务器地址
|
||||
// target: 'http://localhost:9999', // 目标服务器地址
|
||||
target: 'http://110.41.142.124:6379', // 目标服务器地址
|
||||
ws: true, // 是否启用 WebSocket
|
||||
changeOrigin: true, // 是否修改请求头中的 Origin 字段
|
||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||
},
|
||||
'/socket.io': {
|
||||
//target: 'http://192.168.1.105:6379',
|
||||
// target: 'ws://localhost:9999',
|
||||
target: 'ws://110.41.142.124:6379',
|
||||
ws: true,
|
||||
changeOrigin: true,
|
||||
|
|
Loading…
Reference in New Issue
Block a user