mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2026-06-12 20:41:45 +08:00
add:添加罗库版本
This commit is contained in:
parent
55320a8dd3
commit
9ee2aa9735
|
|
@ -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()
|
// const chatUrl = "wss://" + "110.41.142.124" + "/socket.io/admin/rax/chatRoom?token=" + Session.getToken()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const useRemoteWsStore = defineStore("remoteWs", {
|
export const useRemoteWsStore = defineStore("remoteWs", {
|
||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
|
|
@ -26,7 +25,7 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
||||||
remoteTasks: [] as any,
|
remoteTasks: [] as any,
|
||||||
remoteTasksCap: 10,
|
remoteTasksCap: 10,
|
||||||
currentTaskIndex: -1,
|
currentTaskIndex: -1,
|
||||||
varMedicine: ["丙泊酚", "舒芬太尼", "瑞芬太尼", "顺阿曲库胺"],
|
varMedicine: ["丙泊酚", "舒芬太尼", "瑞芬太尼", "顺阿曲库胺", "罗库溴铵"],
|
||||||
fixedMedicine: ["尼卡地平", "艾司洛尔", "麻黄素", "阿托品"],
|
fixedMedicine: ["尼卡地平", "艾司洛尔", "麻黄素", "阿托品"],
|
||||||
exceptionType: ["BIS_except", "DBP_except", "EtCO2_except", "HR_except", "SBP_except", "ST_except"],
|
exceptionType: ["BIS_except", "DBP_except", "EtCO2_except", "HR_except", "SBP_except", "ST_except"],
|
||||||
exceptionMsg: {
|
exceptionMsg: {
|
||||||
|
|
@ -109,6 +108,7 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
||||||
getCloseStatus() {
|
getCloseStatus() {
|
||||||
return this.closeStatus
|
return this.closeStatus
|
||||||
},
|
},
|
||||||
|
|
||||||
/*createConnect(name: string, id: string, date: string, index: number) {
|
/*createConnect(name: string, id: string, date: string, index: number) {
|
||||||
if (!this.patient[name + id + date + index]) {
|
if (!this.patient[name + id + date + index]) {
|
||||||
const vitalWS = new WebSocket(vitalUrl)
|
const vitalWS = new WebSocket(vitalUrl)
|
||||||
|
|
@ -181,6 +181,7 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},*/
|
},*/
|
||||||
|
|
||||||
disconnect(name: string, id: string, date: string, index: number) {
|
disconnect(name: string, id: string, date: string, index: number) {
|
||||||
this.disconnectChat(name, id, date, index)
|
this.disconnectChat(name, id, date, index)
|
||||||
this.disconnectVital(name, id, date, index)
|
this.disconnectVital(name, id, date, index)
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
<!-- </video>-->
|
<!-- </video>-->
|
||||||
<!-- </div>-->
|
<!-- </div>-->
|
||||||
|
|
||||||
<!--聊天框 -->
|
<!--聊天框 -->
|
||||||
<div class="message-box">
|
<div class="message-box">
|
||||||
<ul ref="msgLog" class="message-log">
|
<ul ref="msgLog" class="message-log">
|
||||||
<li v-for="(item, index) in mssageList" :key="'msg-log-' + index"
|
<li v-for="(item, index) in mssageList" :key="'msg-log-' + index"
|
||||||
|
|
@ -387,11 +387,16 @@ function updateMedicineTable(aiMedicine: any, doctorMedicine: any) {
|
||||||
delete aiMedicine.Time;
|
delete aiMedicine.Time;
|
||||||
|
|
||||||
currentAIMedicine = aiMedicine;
|
currentAIMedicine = aiMedicine;
|
||||||
const keys = Object.keys(aiMedicine);
|
// const keys = Object.keys(aiMedicine);
|
||||||
keys.forEach(key => {
|
// console.log(keys);
|
||||||
medicineSpeedTemp[key] = aiMedicine[key];
|
// keys.forEach(key => {
|
||||||
})
|
// medicineSpeedTemp[key] = aiMedicine[key];
|
||||||
|
// })
|
||||||
|
|
||||||
if (varTableData.value.length > 0) {
|
if (varTableData.value.length > 0) {
|
||||||
|
varTableData.value = varTableData.value.filter(medicine => {
|
||||||
|
return medicine.name in aiMedicine; // 只保留存在于 aiMedicine 中的 medicine
|
||||||
|
});
|
||||||
varTableData.value.forEach((medicine: any) => {
|
varTableData.value.forEach((medicine: any) => {
|
||||||
medicine.speed = aiMedicine[medicine.name] ? Number(aiMedicine[medicine.name]).toFixed(2) : '0.0'
|
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'
|
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.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'
|
medicine.total = aiMedicine[medicine.name + "sum"] ? Number(aiMedicine[medicine.name + "sum"]).toFixed(2) : '0.0'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// console.log(varTableData.value)
|
||||||
|
// console.log(fixedTableData.value)
|
||||||
} else {
|
} else {
|
||||||
const varTable: any = [];
|
const varTable: any = [];
|
||||||
const fixedTable: any = [];
|
const fixedTable: any = [];
|
||||||
|
|
@ -625,121 +633,11 @@ function startAI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 聊天室
|
* 聊天室
|
||||||
*/
|
*/
|
||||||
const msgVal = ref('');
|
const msgVal = ref('');
|
||||||
const mssageList = ref([] as any);
|
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>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user