ping值改为后端返回

This commit is contained in:
GranceWang 2024-08-05 14:22:24 +08:00
parent 9c58812420
commit 6bb2d7aff6
2 changed files with 5 additions and 24 deletions

View File

@ -288,7 +288,9 @@ export const useRemoteWsStore = defineStore("remoteWs", {
date: date,
msgType: "init"
}))
this.loopSendMedicinePing(name,id,date,index,()=>{})
if (this.loopSendMedicinePing) {
this.loopSendMedicinePing(name,id,date,index,()=>{})
}
}
}
},

View File

@ -47,7 +47,7 @@
</el-text>
</el-space>
<el-button color="#C77000" @click="viewPatientInfo">患者信息</el-button>
<el-button type="text" color="#C77000">ping{{timeDiffPing||'-'}}</el-button>
<el-button type="text" color="#C77000">ping{{timeDiffPing}}</el-button>
<el-button color="#C77000" @click="connectionUnity('1')" v-if="!whetherControl">连接远程控制</el-button>
<template v-else>
<el-button color="#C77000">已控制</el-button>
@ -267,10 +267,8 @@ const varTableData = ref([] as any[]);
const table1SpeedVal = ref('');
const whetherControl =ref(false);
const subscribeMedicineData=ref(null);
const pingData=ref(0);
const intervalFun=ref(null);
const timeDiffPing=ref(0);
const cachePingFirstTime=ref(0);
let currentAIMedicine: any;
let currentDocMedicine: any;
const medicineSpeedTemp: any = {};
@ -331,7 +329,7 @@ watch(subscribeMedicineData,(newValue:any,oldValue:any)=>{
}
break;
case 'pong':
pingData.value=newValue.msg;
timeDiffPing.value=newValue.msg;
break;
default:
@ -339,21 +337,6 @@ watch(subscribeMedicineData,(newValue:any,oldValue:any)=>{
}
}
})
watch(pingData,(newValue:any,oldValue:any)=>{
if (newValue&&oldValue) {
const timeDiff= Math.abs(newValue - oldValue)
const res= Math.ceil(timeDiff / 10)
timeDiffPing.value=res
}else{
if (newValue) {
const res=Math.abs(newValue - (cachePingFirstTime.value || +new Date())) / 10
timeDiffPing.value=Math.ceil(res)
}else{
timeDiffPing.value= 0 / 10
}
}
})
function createConnect() {
remoteWsStore.createChatConnect(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)
@ -361,10 +344,6 @@ function createConnect() {
function loopSendMedicinePing(){
remoteWsStore.loopSendMedicinePing(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentRemote.value.index,(res:any)=>{})
if (cachePingFirstTime.value) {
return;
}
cachePingFirstTime.value= +new Date()
}
//
function connectionUnity(flag:string){