diff --git a/src/views/voice/recordPage/index.vue b/src/views/voice/recordPage/index.vue index 07ae3d6..a099a12 100644 --- a/src/views/voice/recordPage/index.vue +++ b/src/views/voice/recordPage/index.vue @@ -56,6 +56,7 @@ const settimEnd = ref(null); const judgmentClose = ref(null); //记录10秒后的定时器 +const jiluTime = ref(null); //记录传过来的时候当前的时间戳 const data = reactive({ showModal: false, //展示对话框 @@ -81,8 +82,8 @@ //初始化语音调度websocket服务 function initRecognizeWs() { - data.recognizeWs && data.recognizeWs.close(); data.recognizeWs && data.recognizeWs.onclose(); + data.recognizeWs && data.recognizeWs.close(); let wsuri; if (window.location.protocol.includes('https')) { @@ -108,6 +109,7 @@ data.recognizeWs.onmessage = function (e) { if (e.data == 'notice') { + jiluTime.value = new Date().getTime(); GetTimeClose(e); // 书写一个11秒后的定时器 如果10秒后收到信息就清除定时器 否则11秒后就重新连接 } else if (e.data != '客户端连接成功' && e.data != 'notice') { @@ -226,6 +228,10 @@ * */ // 开始录音 function startRecorder(val) { + // if (new Date().getTime() - jiluTime.value > 10000) { + // initRecognizeWs(); + // } + data.recordStatus = val; // 获取麦克风权限 Recorder.getPermission().then(