mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2026-06-12 15:51:46 +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) {
|
subscribeMedicine(name: string, id: string, date: string, index: number, cb: any) {
|
||||||
const patient = this.patient[name + id + date + index]
|
const patient = this.patient[name + id + date + index]
|
||||||
if (patient) {
|
if (patient) {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
</el-text>
|
</el-text>
|
||||||
</el-space>
|
</el-space>
|
||||||
<el-button color="#C77000" @click="viewPatientInfo">患者信息</el-button>
|
<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" v-if="whetherControl">已控制</el-button>
|
||||||
<el-button color="#C77000" @click="disconnectControl">断开远程控制</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)
|
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() {
|
function disconnect() {
|
||||||
remoteWsStore.disconnectMedicine(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index)
|
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)
|
remoteWsStore.disconnectChat(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index)
|
||||||
|
|
@ -311,6 +321,9 @@ function subscribeWS() {
|
||||||
subscribeMedicine()
|
subscribeMedicine()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const subscribeVital = () => {
|
const subscribeVital = () => {
|
||||||
onVitalClose()
|
onVitalClose()
|
||||||
remoteWsStore.subscribeVital(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index,
|
remoteWsStore.subscribeVital(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index,
|
||||||
|
|
@ -340,7 +353,7 @@ const connectRemote = () => {
|
||||||
const clostHandle = () => {
|
const clostHandle = () => {
|
||||||
console.log("ws关闭成功啦")
|
console.log("ws关闭成功啦")
|
||||||
}
|
}
|
||||||
const messageHandle = ({data}) => {
|
const messageHandle = () => {
|
||||||
console.log("前端接受到的信息啦")
|
console.log("前端接受到的信息啦")
|
||||||
}
|
}
|
||||||
const errorHandle = () => {
|
const errorHandle = () => {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import vue from '@vitejs/plugin-vue'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base: '/medical/',
|
base: '/',
|
||||||
plugins: [vue()],
|
plugins: [vue()],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
|
|
@ -25,13 +25,14 @@ export default defineConfig({
|
||||||
'/api': {
|
'/api': {
|
||||||
//target: 'http://localhost:9999', // 目标服务器地址
|
//target: 'http://localhost:9999', // 目标服务器地址
|
||||||
//target: 'http://192.168.1.105:6379', // 目标服务器地址
|
//target: 'http://192.168.1.105:6379', // 目标服务器地址
|
||||||
|
// target: 'http://localhost:9999', // 目标服务器地址
|
||||||
target: 'http://110.41.142.124:6379', // 目标服务器地址
|
target: 'http://110.41.142.124:6379', // 目标服务器地址
|
||||||
ws: true, // 是否启用 WebSocket
|
ws: true, // 是否启用 WebSocket
|
||||||
changeOrigin: true, // 是否修改请求头中的 Origin 字段
|
changeOrigin: true, // 是否修改请求头中的 Origin 字段
|
||||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||||
},
|
},
|
||||||
'/socket.io': {
|
'/socket.io': {
|
||||||
//target: 'http://192.168.1.105:6379',
|
// target: 'ws://localhost:9999',
|
||||||
target: 'ws://110.41.142.124:6379',
|
target: 'ws://110.41.142.124:6379',
|
||||||
ws: true,
|
ws: true,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user