|
|
@@ -59,13 +59,19 @@
|
|
|
<SvgIcon icon-class="luyin-delete" size="24" />
|
|
|
</a>
|
|
|
<el-button
|
|
|
+ v-if="showScoring"
|
|
|
type="text"
|
|
|
- :class="['record-score-btn', wholeRecordSelectList[selectWholeIndex] ? 'record-score-btn-has' : '']"
|
|
|
+ :class="[
|
|
|
+ 'record-score-btn',
|
|
|
+ wholeRecordSelectList[selectWholeIndex] && wholeRecordSelectList[selectWholeIndex].isScore
|
|
|
+ ? 'record-score-btn-has'
|
|
|
+ : '',
|
|
|
+ ]"
|
|
|
@click="handleWholeScore()"
|
|
|
>评分</el-button
|
|
|
>
|
|
|
<RecordProgressBar
|
|
|
- v-if="microWholeStatus"
|
|
|
+ v-if="microWholeStatus && showScoring"
|
|
|
:index="luyinIndex"
|
|
|
:total="totalIndex"
|
|
|
:unit="recordType === 'sentence' ? '句' : '词'"
|
|
|
@@ -167,6 +173,7 @@ export default {
|
|
|
type: Array,
|
|
|
default: () => [],
|
|
|
},
|
|
|
+ showScoring: { type: Boolean, default: true },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -232,6 +239,7 @@ export default {
|
|
|
this.isPlaying = false;
|
|
|
this.recordtime = this.wholeRecordSelectList[this.selectWholeIndex].toltime;
|
|
|
this.playtime = 0;
|
|
|
+ clearInterval(this.timer);
|
|
|
});
|
|
|
// 登记录音器,供提交前统一停止(停止会触发录音上传)
|
|
|
this.unregisterRecorder = registerRecorder({ stopIfRecording: () => this.stopIfRecording() });
|
|
|
@@ -261,21 +269,28 @@ export default {
|
|
|
// 点击开始录音按钮
|
|
|
changeMicroStatus() {
|
|
|
this.microWholeStatus = !this.microWholeStatus;
|
|
|
- this.$emit('changeWholeStatus', this.microWholeStatus, 0);
|
|
|
- this.luyinIndex = 0;
|
|
|
- this.handleDestroyRecord();
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.microWholeStatus) {
|
|
|
- this.recordList = new Array(this.totalIndex).fill();
|
|
|
- this.microphone();
|
|
|
- }
|
|
|
- });
|
|
|
+ if (this.showScoring) {
|
|
|
+ // 整体评分录音模式
|
|
|
+ this.$emit('changeWholeStatus', this.microWholeStatus, 0);
|
|
|
+ this.luyinIndex = 0;
|
|
|
+ this.handleDestroyRecord();
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.microWholeStatus) {
|
|
|
+ this.recordList = new Array(this.totalIndex).fill();
|
|
|
+ this.microphone();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 普通录音模式
|
|
|
+ this.microphone();
|
|
|
+ }
|
|
|
},
|
|
|
// 重置销毁录音
|
|
|
handleDestroyRecord() {
|
|
|
if (this.timer) clearInterval(this.timer);
|
|
|
this.$root.isRecording = false;
|
|
|
this.microphoneStatus = false;
|
|
|
+ this.$emit('changeIsRecord', this.microphoneStatus);
|
|
|
this.recordStartPromise = null;
|
|
|
this.recordtime = 0;
|
|
|
this.hasMicro = '';
|
|
|
@@ -303,12 +318,14 @@ export default {
|
|
|
// 点击下一个按钮
|
|
|
handleNext(type) {
|
|
|
if (type === 'finish') {
|
|
|
+ this.isAllDone = false;
|
|
|
this.handleStopRecording();
|
|
|
this.microWholeStatus = false;
|
|
|
this.wholeRecordSelectList.push({
|
|
|
name: `整体录音${this.wholeRecordSelectList.length + 1}`,
|
|
|
src: '',
|
|
|
toltime: 0,
|
|
|
+ isScore: true,
|
|
|
});
|
|
|
this.selectWholeIndex = this.wholeRecordSelectList.length - 1;
|
|
|
this.timers = setInterval(() => {
|
|
|
@@ -370,10 +387,29 @@ export default {
|
|
|
// 开始录音
|
|
|
microphone() {
|
|
|
if (!this.taskModel || this.taskModel !== 'ANSWER') {
|
|
|
- if (this.microphoneStatus) {
|
|
|
- this.handleStopRecording();
|
|
|
+ if (this.showScoring) {
|
|
|
+ // 整体录音评分模式
|
|
|
+ if (this.microphoneStatus) {
|
|
|
+ this.handleStopRecording();
|
|
|
+ } else {
|
|
|
+ this.startRecording();
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.startRecording();
|
|
|
+ if (this.microphoneStatus) {
|
|
|
+ this.handleStopRecordingNormal();
|
|
|
+ this.wholeRecordSelectList.push({
|
|
|
+ name: `录音${this.wholeRecordSelectList.length + 1}`,
|
|
|
+ src: '',
|
|
|
+ toltime: 0,
|
|
|
+ isScore: false,
|
|
|
+ });
|
|
|
+ this.selectWholeIndex = this.wholeRecordSelectList.length - 1;
|
|
|
+
|
|
|
+ this.$emit('updataWholeRecordList', this.recordList);
|
|
|
+ this.$emit('getWholeRecordIndex', this.wholeRecordSelectList.length - 1);
|
|
|
+ } else {
|
|
|
+ this.startRecordingNormal();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
@@ -395,6 +431,7 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
this.microphoneStatus = true;
|
|
|
+ this.$emit('changeIsRecord', this.microphoneStatus);
|
|
|
this.recordtime = 0;
|
|
|
this.isPlaying = false;
|
|
|
clearInterval(this.timer);
|
|
|
@@ -450,6 +487,7 @@ export default {
|
|
|
clearInterval(this.timer);
|
|
|
this.$root.isRecording = false;
|
|
|
this.microphoneStatus = false;
|
|
|
+ this.$emit('changeIsRecord', this.microphoneStatus);
|
|
|
this.recordStartPromise = null;
|
|
|
this.recordtime = 0;
|
|
|
this.hasMicro = '';
|
|
|
@@ -481,6 +519,7 @@ export default {
|
|
|
if (this.stopPromise === stopPromise) this.stopPromise = null;
|
|
|
if (this.microphoneStatus) {
|
|
|
this.microphoneStatus = false;
|
|
|
+ this.$emit('changeIsRecord', this.microphoneStatus);
|
|
|
this.$root.isRecording = false;
|
|
|
clearInterval(this.timer);
|
|
|
}
|
|
|
@@ -504,6 +543,7 @@ export default {
|
|
|
// 录音结束立即释放录音占用的 AudioContext 与麦克风流,避免多次录音不断累积
|
|
|
releaseRecorder(recorder);
|
|
|
this.microphoneStatus = false;
|
|
|
+ this.$emit('changeIsRecord', this.microphoneStatus);
|
|
|
this.hasMicro = 'normal';
|
|
|
|
|
|
const index = this.selectIndex;
|
|
|
@@ -554,6 +594,17 @@ export default {
|
|
|
.then((res) => {
|
|
|
patchTarget({ wavData: res.file_id, file_url: res.file_url || '', upload_state: 'done' });
|
|
|
if (this.selectIndex === index) this.wavblob = res.file_id;
|
|
|
+ if (!this.showScoring) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.wholeRecordSelectList[this.selectWholeIndex].src =
|
|
|
+ this.recordList[this.recordList.length - 1].file_url;
|
|
|
+ this.wholeRecordSelectList[this.selectWholeIndex].audio_file_id =
|
|
|
+ this.recordList[this.recordList.length - 1].wavData;
|
|
|
+ this.wholeRecordSelectList[this.selectWholeIndex].toltime =
|
|
|
+ this.recordList[this.recordList.length - 1].toltime;
|
|
|
+ this.recordtime = this.recordList[this.recordList.length - 1].toltime;
|
|
|
+ });
|
|
|
+ }
|
|
|
emitAnswer();
|
|
|
})
|
|
|
// 上传失败:保留 dataURL 并标记状态,由提交前统一决策
|
|
|
@@ -781,6 +832,70 @@ export default {
|
|
|
// this.curQue.Bookanswer.practiceModel[this.sentIndex].scoreList[this.selectIndex] = scoreObj;
|
|
|
return scoreObj;
|
|
|
},
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开始录音
|
|
|
+ */
|
|
|
+ startRecordingNormal() {
|
|
|
+ this.hasMicro = '';
|
|
|
+ this.$root.isRecording = true;
|
|
|
+ this.$emit('getWavblob', null);
|
|
|
+ this.$emit('getSelectData', { type: '' });
|
|
|
+ // 开始录音
|
|
|
+ const recorder = this.getRecorder();
|
|
|
+ const startPromise = recorder.start();
|
|
|
+ this.recordStartPromise = startPromise;
|
|
|
+ if (startPromise && typeof startPromise.catch === 'function') {
|
|
|
+ startPromise.catch((err) => {
|
|
|
+ if (this.recordStartPromise === startPromise) this.handleRecordStartFail(err);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.microphoneStatus = true;
|
|
|
+ this.$emit('changeIsRecord', this.microphoneStatus);
|
|
|
+ this.recordtime = 0;
|
|
|
+ this.isPlaying = false;
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.timer = setInterval(() => {
|
|
|
+ if (this.recordtime < 600) {
|
|
|
+ this.recordtime += 1;
|
|
|
+ } else {
|
|
|
+ // 与创作端保持一致的单条录音上限,避免产生超大录音
|
|
|
+ this.$message.warning('单条记录最多可以录音10分钟');
|
|
|
+ this.microphone();
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ this.$emit('handleParentPlay');
|
|
|
+ let obj = {
|
|
|
+ name: this.fileName ? this.fileName + this.recordFile : `新录音${this.recordFile}`,
|
|
|
+ id: (this.recordFile + Math.random().toString(36).substring(2, 12)).toString(),
|
|
|
+ };
|
|
|
+ if (this.selectData) obj.selectData = this.selectData;
|
|
|
+ this.recordList.push(obj);
|
|
|
+ this.recordFile += 1;
|
|
|
+ this.selectIndex = this.recordList.length - 1;
|
|
|
+ // 记住本次录音对应哪一条,停止时按 id 回写,避免列表被父组件回灌后写到别的条目上
|
|
|
+ this.recordingId = obj.id;
|
|
|
+ this.$emit('getRecordIndex', this.selectIndex);
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 停止录音并把录音上传到文件服务器。
|
|
|
+ * 录音先以 dataURL 写回答案(结构完整、可立即试听),上传成功后再替换为 file_id,
|
|
|
+ * 避免答案里内联 MB 级 base64 导致提交请求超时。
|
|
|
+ */
|
|
|
+ handleStopRecordingNormal() {
|
|
|
+ if (this.stopPromise) return this.stopPromise;
|
|
|
+ const stopPromise = this.finishStopRecording().finally(() => {
|
|
|
+ if (this.stopPromise === stopPromise) this.stopPromise = null;
|
|
|
+ if (this.microphoneStatus) {
|
|
|
+ this.microphoneStatus = false;
|
|
|
+ this.$emit('changeIsRecord', this.microphoneStatus);
|
|
|
+ this.$root.isRecording = false;
|
|
|
+ clearInterval(this.timer);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.stopPromise = stopPromise;
|
|
|
+ return stopPromise;
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
/* istanbul ignore next */ /* c8 ignore start */ /* eslint-disable */ function oo_cm() {
|
|
|
@@ -937,11 +1052,11 @@ export default {
|
|
|
.record-score-btn {
|
|
|
padding: 0 9px;
|
|
|
font-weight: bold;
|
|
|
- color: #3b6fd4;
|
|
|
+ color: #c0c4cc;
|
|
|
cursor: not-allowed;
|
|
|
- opacity: 0.35;
|
|
|
|
|
|
&-has {
|
|
|
+ color: #3b6fd4;
|
|
|
cursor: pointer;
|
|
|
opacity: 1;
|
|
|
}
|