From 0d708632ea8dff402e0fde86e652f34820917e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=B2=A9?= Date: Wed, 17 Sep 2025 22:30:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=AD=E9=9F=B3=E6=8E=89?= =?UTF-8?q?=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/common.js | 10 ++++++---- src/components/examination/question.vue | 1 - src/components/examination/touchBtn.vue | 20 ++++++++++++++------ src/pages/examination/index.vue | 17 +++++++++-------- src/pages/practice/index.vue | 7 +++++-- src/pages/wrongQuestionRecord/correct.vue | 12 ++++++++++-- 6 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/api/common.js b/src/api/common.js index 3fd4c96e..6b581b7d 100644 --- a/src/api/common.js +++ b/src/api/common.js @@ -86,22 +86,24 @@ export const commonUploadVoiceFile = (file, url, data = {}, fileKey = 'voice') = filePath: file, name: fileKey, formData: data, + timeout: 6000, success(result) { try { const res = JSON.parse(result.data); if (res.rtnCode === '0000') { - resolve(result); + return resolve(result); } else if (REQUES_ERROR_CODES['NO_LOGIN'].includes(res.rtnCode)) { goto_login_fun() - } else { - reject(new Error(res.message)); + return reject('NO_LOGIN'); } + return reject('Other'); } catch (error) { reject(new Error('Failed to parse response')); } }, fail(error) { - reject(new Error('Upload failed')); + console.log('err', error); + return reject('Other'); } }); }); diff --git a/src/components/examination/question.vue b/src/components/examination/question.vue index 2d8693d3..ce182717 100644 --- a/src/components/examination/question.vue +++ b/src/components/examination/question.vue @@ -206,7 +206,6 @@ // 赋值显示 console.log('displayTime', displayTime); voiceTime.value = displayTime + 's'; - console.log('displayTime', voiceTime.value); }); watch( () => props.dataInfo.voicePath, diff --git a/src/components/examination/touchBtn.vue b/src/components/examination/touchBtn.vue index 63ae6fd5..8be65c9f 100644 --- a/src/components/examination/touchBtn.vue +++ b/src/components/examination/touchBtn.vue @@ -148,6 +148,7 @@ }; // 结束录音 const stopRecord = (status = false) => { + console.log('结束录音stopRecord', status); if (props.isDisabled) return; if (startTimer.value) { clearTimeout(startTimer.value); @@ -162,10 +163,12 @@ const times = Math.max(500 - endTime + startTime, 0); setTimeout(() => { console.log('延迟数据', times); - nextTick(() => { - popupRef.value.close(); - recorderManager.stop(); - }); + // nextTick(() => { + + // }); + popupRef.value.close(); + console.log('停止录音'); + recorderManager.stop(); }, times); } nextTick(() => (recordingStatus.value = 'not_started')); @@ -181,13 +184,18 @@ console.log('说话时长', recordDuration); if (props.minRecordDuration > recordDuration) { nextTick(() => common.msg('说话时间太短,没有听清!')); + // console.log('说话时间太短,没有听清'); return; } - - stopRecord(true); // 在去主动执行一次关闭 + popupRef.value?.close(); + recordingStatus.value = 'not_started' + // stopRecord(true); // 在去主动执行一次关闭 console.log('录音结束,时长:', recordDuration, '秒'); emit('submit', 'voice', res.tempFilePath); }); + recorderManager.onError(function (err) { + console.log('录音错误', err); + }); recorderManager.onStart(function (res) { // 检测是否已经抬手结束了 console.log('检测是否已经抬手结束了', recordingStatus.value); diff --git a/src/pages/examination/index.vue b/src/pages/examination/index.vue index c39ecf01..8e403499 100644 --- a/src/pages/examination/index.vue +++ b/src/pages/examination/index.vue @@ -190,10 +190,9 @@ papersId: '', // 试卷ID limitTm: 0, // 考试限制时间 papersName: '', // 试卷名称 - isCacheExam: '' ,// 是否是缓存试卷(继续答题试卷) - flagQuery: '' , - flagQueryDetail: '' , - + isCacheExam: '', // 是否是缓存试卷(继续答题试卷) + flagQuery: '', + flagQueryDetail: '' }); // 试卷信息 const topicList = reactive([]); // 问题列表 const popup_input_bottom = ref('0px'); @@ -304,6 +303,7 @@ const topic = topicList[questionNumber.value]; touchBtnRef.value?.clearinputText(); // 清除发送框数据 if (type === 'voice') { + if(topic.es_status == '00') return; topic.es_status = '00'; // 00转圈 const voicePath = submitObj; commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {}) @@ -326,9 +326,11 @@ } } }) - .catch((err) => { + .catch((error) => { topic.es_status = ''; // 取消转圈 - common.msg('系统异常,请联系管理员'); + if (error === 'Other') { + common.msg('系统异常,请联系管理员'); + } }); } else if (type === 'text') { topic.es_status = '01'; @@ -339,14 +341,13 @@ } }; - const answerCacheList = ref({}); const setAnswerCacheList = (value) => { console.log('触发变化', value); answerCacheList.value = value; common.setValue(examinationAnswerCacheKey, value); }; - + // 添加试题答案缓存 const addTopicAnswerCache = () => { const my_answer = topic.value.my_answer; diff --git a/src/pages/practice/index.vue b/src/pages/practice/index.vue index 0810d20d..b5c6e187 100644 --- a/src/pages/practice/index.vue +++ b/src/pages/practice/index.vue @@ -306,6 +306,7 @@ const topic = topicList[questionNumber.value] touchBtnRef.value?.clearinputText(); // 清除发送框数据 if (type === 'voice') { + if(topic.es_status == '00') return; topic.es_status = '00'; // 00转圈 const voicePath = submitObj; commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {}) @@ -327,9 +328,11 @@ } } }) - .catch((err) => { + .catch((error) => { topic.es_status = ''; // 取消转圈 - common.msg('系统异常,请联系管理员'); + if (error === 'Other') { + common.msg('系统异常,请联系管理员'); + } }); } else if (type === 'text') { topic.es_status = '01'; diff --git a/src/pages/wrongQuestionRecord/correct.vue b/src/pages/wrongQuestionRecord/correct.vue index 84fe1ffc..14eeb2d1 100644 --- a/src/pages/wrongQuestionRecord/correct.vue +++ b/src/pages/wrongQuestionRecord/correct.vue @@ -287,18 +287,24 @@ const touchBtnSubmit = (type, submitObj) => { const topic = topicList[questionNumber.value]; touchBtnRef.value?.clearinputText(); // 清除发送框数据 + console.log('录音组件提交'); if (type === 'voice') { + if(topic.es_status == '00') return; topic.es_status = '00'; // 00转圈 const voicePath = submitObj; commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {}) .then((res) => { + console.log('_contentsssss', res); let _res = JSON.parse(res.data); if (_res.rtnCode === '0000') { const _content = _res.body.transContent.trim(); + console.log('_content', _content); if (_content === '') { topic.es_status = ''; // 取消转圈 + console.log('未识别到文字'); return common.msg('未识别到文字'); } else { + console.log('识别到了文字', _content); topic.es_status = '02'; topic.my_answer = { anserResult: _res.body.transContent, @@ -309,9 +315,11 @@ } } }) - .catch((err) => { + .catch((error) => { topic.es_status = ''; // 取消转圈 - common.msg('系统异常,请联系管理员'); + if (error === 'Other') { + common.msg('系统异常,请联系管理员'); + } }); } else if (type === 'text') { topic.es_status = '01';