From 455527513a634ad19d26efa64a670a6bdf36cb32 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Sat, 14 Oct 2023 17:05:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8C=87=E4=BB=A4=E6=8E=A5?= =?UTF-8?q?=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/chat/index.vue | 51 +++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/src/views/chat/index.vue b/src/views/chat/index.vue index f9e9452..73cbb15 100644 --- a/src/views/chat/index.vue +++ b/src/views/chat/index.vue @@ -45,6 +45,45 @@ const connection = new Push({ // 是否正在录音 const recordFalg = ref(0) +/** + * APP端命令目录 + * start 开始录音 + * end 录音完成 + * re 重新录制 + * clear 清空对话 + * pause 暂停播放 + * play 继续播放 + * stop 停止播放 + * re-play 重新播放 + */ +const runOrder = (e)=>{ + switch(e){ + case 'start': startOrder();break; + case 'end':endOrder();break; + } +} + +const startOrder = ()=>{ + if (recordFalg.value == 0) { + RecordXunfei() + recordFalg.value = 1 + nowStatus.value = 'record' + }else { + console.log('无效指令'); + } +} + +const endOrder = ()=>{ + if(recordFalg.value==1){ + RecordXunfei() + recordFalg.value = 0 + nowStatus.value = 'loding' + handleSubmit() + }else { + console.log('无效指令'); + } +} + // 假设用户uid为1 const uid = 1 // 浏览器监听user-1频道的消息,也就是用户uid为1的用户消息 @@ -54,17 +93,7 @@ console.log(user_channel) user_channel.on('message', (data: any) => { // data里是消息内容 console.log('收到命令', data) - if (recordFalg.value == 0) { - RecordXunfei() - recordFalg.value = 1 - nowStatus.value = 'record' - } - else { - RecordXunfei() - recordFalg.value = 0 - nowStatus.value = 'loding' - handleSubmit() - } + runOrder(data.content) }) const changeRecord = () => {