Merge branch 'master' of https://gitee.com/xiao12feng/xinli
This commit is contained in:
commit
12d943db6c
|
|
@ -151,7 +151,20 @@ export default {
|
|||
return this.totalItems > 0 ? Math.round((this.currentIndex + 1) / this.totalItems * 100) : 0;
|
||||
},
|
||||
answeredCount() {
|
||||
return this.itemList.filter(item => this.isItemAnswered(item, this.answersMap[item.itemId])).length;
|
||||
// 计算已答题数量
|
||||
return this.itemList.filter(item => {
|
||||
const answer = this.answersMap[item.itemId];
|
||||
if (!answer) {
|
||||
return false;
|
||||
}
|
||||
// 单选题需要 optionId,多选题需要 optionIds(字符串,用逗号分隔)
|
||||
if (item.itemType === 'single') {
|
||||
return answer.optionId != null;
|
||||
} else if (item.itemType === 'multiple') {
|
||||
return answer.optionIds != null && answer.optionIds.trim().length > 0;
|
||||
}
|
||||
return true;
|
||||
}).length;
|
||||
},
|
||||
isComplete() {
|
||||
if (this.itemList.length === 0) {
|
||||
|
|
@ -215,18 +228,22 @@ export default {
|
|||
hasStarted = true;
|
||||
};
|
||||
this.currentUtterance.onerror = (event) => {
|
||||
const errorType = event.error || '';
|
||||
// 忽略 interrupted 和 canceled 错误(这些是正常的中断,不是真正的错误)
|
||||
const ignoredErrors = ['interrupted', 'canceled'];
|
||||
if (ignoredErrors.includes(errorType)) {
|
||||
console.log('TTS 被中断(正常情况):', errorType);
|
||||
return;
|
||||
}
|
||||
console.error('TTS 错误:', event);
|
||||
if (hasStarted) {
|
||||
return;
|
||||
}
|
||||
const errorType = event.error || '';
|
||||
const seriousErrors = ['network-error', 'synthesis-failed', 'synthesis-unavailable', 'not-allowed'];
|
||||
if (seriousErrors.includes(errorType)) {
|
||||
this.$message.error('语音朗读失败:' + this.getErrorMessage(errorType));
|
||||
} else if (errorType === 'text-too-long') {
|
||||
this.$message.warning('文本过长,无法朗读');
|
||||
} else if (errorType) {
|
||||
this.$message.error('语音朗读失败');
|
||||
}
|
||||
};
|
||||
try {
|
||||
|
|
@ -297,7 +314,6 @@ export default {
|
|||
answerScore: answer.answerScore
|
||||
};
|
||||
});
|
||||
this.currentIndex = this.determineResumeIndex();
|
||||
|
||||
// 加载所有题目的选项
|
||||
this.loadAllOptions().then(() => {
|
||||
|
|
@ -391,34 +407,6 @@ export default {
|
|||
this.loadCurrentAnswer();
|
||||
}
|
||||
},
|
||||
isItemAnswered(item, answer) {
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
if (!answer) {
|
||||
return false;
|
||||
}
|
||||
if (item.itemType === 'single') {
|
||||
return answer.optionId != null && answer.optionId !== undefined;
|
||||
}
|
||||
if (item.itemType === 'multiple') {
|
||||
return answer.optionIds != null && String(answer.optionIds).trim().length > 0;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
determineResumeIndex() {
|
||||
if (!this.itemList || this.itemList.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
for (let i = 0; i < this.itemList.length; i++) {
|
||||
const item = this.itemList[i];
|
||||
const answered = this.isItemAnswered(item, this.answersMap[item.itemId]);
|
||||
if (!answered) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return this.itemList.length - 1;
|
||||
},
|
||||
/** 加载当前题目的答案 */
|
||||
loadCurrentAnswer() {
|
||||
if (!this.currentItem) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user