add:添加罗库版本

This commit is contained in:
republicline 2024-11-25 12:37:36 +08:00
parent 55320a8dd3
commit 9ee2aa9735
2 changed files with 16 additions and 117 deletions

View File

@ -18,7 +18,6 @@ const chatUrl = "ws://" + window.location.host + "/socket.io/admin/rax/chatRoom?
// const chatUrl = "wss://" + "110.41.142.124" + "/socket.io/admin/rax/chatRoom?token=" + Session.getToken()
export const useRemoteWsStore = defineStore("remoteWs", {
state: () => {
return {
@ -26,7 +25,7 @@ export const useRemoteWsStore = defineStore("remoteWs", {
remoteTasks: [] as any,
remoteTasksCap: 10,
currentTaskIndex: -1,
varMedicine: ["丙泊酚", "舒芬太尼", "瑞芬太尼", "顺阿曲库胺"],
varMedicine: ["丙泊酚", "舒芬太尼", "瑞芬太尼", "顺阿曲库胺", "罗库溴铵"],
fixedMedicine: ["尼卡地平", "艾司洛尔", "麻黄素", "阿托品"],
exceptionType: ["BIS_except", "DBP_except", "EtCO2_except", "HR_except", "SBP_except", "ST_except"],
exceptionMsg: {
@ -109,6 +108,7 @@ export const useRemoteWsStore = defineStore("remoteWs", {
getCloseStatus() {
return this.closeStatus
},
/*createConnect(name: string, id: string, date: string, index: number) {
if (!this.patient[name + id + date + index]) {
const vitalWS = new WebSocket(vitalUrl)
@ -181,6 +181,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)

View File

@ -76,7 +76,7 @@
<!-- </video>-->
<!-- </div>-->
<!--聊天框 -->
<!--聊天框 -->
<div class="message-box">
<ul ref="msgLog" class="message-log">
<li v-for="(item, index) in mssageList" :key="'msg-log-' + index"
@ -387,11 +387,16 @@ function updateMedicineTable(aiMedicine: any, doctorMedicine: any) {
delete aiMedicine.Time;
currentAIMedicine = aiMedicine;
const keys = Object.keys(aiMedicine);
keys.forEach(key => {
medicineSpeedTemp[key] = aiMedicine[key];
})
// const keys = Object.keys(aiMedicine);
// console.log(keys);
// keys.forEach(key => {
// medicineSpeedTemp[key] = aiMedicine[key];
// })
if (varTableData.value.length > 0) {
varTableData.value = varTableData.value.filter(medicine => {
return medicine.name in aiMedicine; // aiMedicine medicine
});
varTableData.value.forEach((medicine: any) => {
medicine.speed = aiMedicine[medicine.name] ? Number(aiMedicine[medicine.name]).toFixed(2) : '0.0'
medicine.total = aiMedicine[medicine.name + "sum"] ? Number(aiMedicine[medicine.name + "sum"]).toFixed(2) : '0.0'
@ -400,6 +405,9 @@ function updateMedicineTable(aiMedicine: any, doctorMedicine: any) {
medicine.speed = aiMedicine[medicine.name] ? Number(aiMedicine[medicine.name]).toFixed(2) : '0.0'
medicine.total = aiMedicine[medicine.name + "sum"] ? Number(aiMedicine[medicine.name + "sum"]).toFixed(2) : '0.0'
})
// console.log(varTableData.value)
// console.log(fixedTableData.value)
} else {
const varTable: any = [];
const fixedTable: any = [];
@ -625,121 +633,11 @@ function startAI() {
}
/*
* 聊天室
*/
const msgVal = ref('');
const mssageList = ref([] as any);
const isRecording = ref(false); //
const mediaRecorder = ref(null);
const audioChunks = ref([]);
const remainingTime = ref(10); // 10
//
const startRecording = async () => {
if (isRecording.value) return; //
isRecording.value = true; //
remainingTime.value = 10; // 10
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
mediaRecorder.value = new MediaRecorder(stream);
//
mediaRecorder.value.ondataavailable = (event) => {
console.log("录音中...")
audioChunks.value.push(event.data);
console.log("当前音频数据块:", event.data); //
};
//
mediaRecorder.value.onstop = async () => {
isRecording.value = false; //
clearInterval(timer); //
if (audioChunks.value.length === 0) {
console.error("没有音频数据可用于创建 Blob");
return;
}
// Blob
const audioBlob = new Blob(audioChunks.value, {type: 'audio/webm; codecs=opus'});
try {
// Base64
const base64Audio = await convertBlobToBase64(audioBlob);
console.log("转换后的 Base64 字符串:", base64Audio);
// WebSocket
const index = remoteWsStore.getCurrentTaskIndex();
//
remoteWsStore.sendAudio(
currentRemote.value.patient,
currentRemote.value.patientId,
currentRemote.value.date,
base64Audio,
index,
function (res) {
if (res.code == 1) {
ElMessage.error(res.msg);
}
});
} catch (error) {
console.error("转换为 Base64 失败:", error);
}
audioChunks.value = []; // :
};
//
mediaRecorder.value.start();
console.log("录音已开始"); //
// 10
const timer = setInterval(() => {
if (remainingTime.value > 0) {
remainingTime.value--; // 1
} else {
stopRecording(); // 0
console.log("录音时间到,已自动停止!");
}
}, 1000); //
};
/**
* Blob 对象转换为 Base64 字符串
* @param {Blob} blob - 需要转换的 Blob 对象
* @returns {Promise<string>} - 返回一个 Promise解析为 Base64 字符串
*/
const convertBlobToBase64 = (blob) => {
return new Promise((resolve, reject) => {
const reader = new FileReader(); // FileReader
// onloadend
reader.onloadend = () => {
// result URL
const base64String = reader.result.split(',')[1]; // Base64
resolve(base64String); // Base64
};
//
reader.onerror = (error) => {
reject(error); //
};
// Blob URL
reader.readAsDataURL(blob);
});
};
//
const stopRecording = () => {
if (mediaRecorder.value) {
mediaRecorder.value.stop();
isRecording.value = false; //
}
};
</script>